From: theadib Date: Wed, 16 Jan 2008 23:31:51 +0000 (+0000) Subject: now act on settings in dialogue X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=861fa436e7a6d6ff3eaa889b2298e0b82a0b238c;p=inkscape.git now act on settings in dialogue --- diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index b3cf1fa26..b163f2aff 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -53,7 +53,7 @@ CairoPsOutput::check (Inkscape::Extension::Extension * module) return TRUE;} static bool -ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap) +ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap, int resolution) { CairoRenderer *renderer; CairoRenderContext *ctx; @@ -73,6 +73,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l ctx->setPSLevel(level); ctx->setTextToPath(texttopath); ctx->setFilterToBitmap(filtertobitmap); + ctx->setBitmapResolution(resolution); bool ret = ctx->setPsTarget(filename); if(ret) { @@ -149,11 +150,28 @@ CairoPsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gc g_warning("Parameter might not exists"); } + int old_bitmapResolution = 72; + int new_bitmapResolution = 72; + try { + old_bitmapResolution = ext->get_param_int("resolution"); + new_bitmapResolution = mod->get_param_int("resolution"); + ext->set_param_int("resolution", new_bitmapResolution); + } + catch(...) { + g_warning("Parameter might not exists"); + } + gchar * final_name; final_name = g_strdup_printf("> %s", uri); - ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap); + ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution); g_free(final_name); + try { + ext->set_param_int("resolution", old_bitmapResolution); + } + catch(...) { + g_warning("Parameter might not exists"); + } try { ext->set_param_bool("blurToBitmap", old_blurToBitmap); } diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 4c4fd58b2..d7fbbc1aa 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -108,6 +108,7 @@ CairoRenderContext::CairoRenderContext(CairoRenderer *parent) : _ps_level(1), _is_texttopath(FALSE), _is_filtertobitmap(FALSE), + _bitmapresolution(72), _stream(NULL), _is_valid(FALSE), _vector_based_target(FALSE), @@ -394,6 +395,11 @@ void CairoRenderContext::setPSLevel(unsigned int level) _ps_level = level; } +unsigned int CairoRenderContext::getPSLevel(void) +{ + return _ps_level; +} + void CairoRenderContext::setPDFLevel(unsigned int level) { _pdf_level = level; @@ -409,6 +415,21 @@ void CairoRenderContext::setFilterToBitmap(bool filtertobitmap) _is_filtertobitmap = filtertobitmap; } +bool CairoRenderContext::getFilterToBitmap(void) +{ + return _is_filtertobitmap; +} + +void CairoRenderContext::setBitmapResolution(int resolution) +{ + _bitmapresolution = resolution; +} + +int CairoRenderContext::getBitmapResolution(void) +{ + return _bitmapresolution; +} + cairo_surface_t* CairoRenderContext::getSurface(void) { diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 58b0a10e2..595043467 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -88,9 +88,14 @@ public: bool setSurfaceTarget(cairo_surface_t *surface, bool is_vector); void setPSLevel(unsigned int level); + unsigned int getPSLevel(void); void setPDFLevel(unsigned int level); void setTextToPath(bool texttopath); + bool getTextToPath(void); void setFilterToBitmap(bool filtertobitmap); + bool getFilterToBitmap(void); + void setBitmapResolution(int resolution); + int getBitmapResolution(void); /** Creates the cairo_surface_t for the context with the given width, height and with the currently set target @@ -150,6 +155,7 @@ protected: unsigned int _ps_level; bool _is_texttopath; bool _is_filtertobitmap; + int _bitmapresolution; FILE *_stream; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 228154f04..22b2dd606 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -176,10 +176,6 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) NR::Matrix const i2d = sp_item_i2d_affine(item); SPStyle* style = SP_OBJECT_STYLE (item); - if(style->filter.set != 0) { - sp_asbitmap_render(item, ctx); - return; - } CairoRenderer *renderer = ctx->getRenderer(); NRBPath bp; @@ -386,7 +382,11 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) double res; /** @TODO reimplement the resolution stuff */ - res = PX_PER_IN; + res = ctx->getBitmapResolution(); + if(res == 0) { + res = PX_PER_IN; + } + // The width and height of the bitmap in pixels unsigned width = (unsigned) floor ((bbox.x1 - bbox.x0) * res / PX_PER_IN); @@ -486,7 +486,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) { SPStyle* style = SP_OBJECT_STYLE (item); - if(style->filter.set != 0) { + if((ctx->getFilterToBitmap() == TRUE) && (style->filter.set != 0)) { return sp_asbitmap_render(item, ctx); }