From: acspike Date: Fri, 5 Sep 2008 04:07:55 +0000 (+0000) Subject: Make rasterization of filters into pdf respect the requested dpi. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=479ed85bac2b7467a6678bae572404e33465a5d9;p=inkscape.git Make rasterization of filters into pdf respect the requested dpi. This is patch is the result of cooperation between John Cliff, Josh Blocher and myself. There remains an issue with the positioning of filtered objects that originally possessed transforms. --- diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index bd2570652..96366e592 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -219,7 +219,7 @@ CairoRendererPdfOutput::init (void) "<_item value='PDF14'>" N_("PDF 1.4") "\n" "\n" "false\n" - "false\n" + "false\n" "90\n" "false\n" "false\n" diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index be9953ae1..bb4a48d68 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -410,8 +410,6 @@ static void sp_root_render(SPItem *item, CairoRenderContext *ctx) */ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) { - g_warning("render as bitmap"); - //the code now was copied from sp_selection_create_bitmap_copy SPDocument *document = SP_OBJECT(item)->document; @@ -443,8 +441,12 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) // The width and height of the bitmap in pixels - unsigned width = (unsigned) floor ((bbox.x1 - bbox.x0) * res / PX_PER_IN); - unsigned height =(unsigned) floor ((bbox.y1 - bbox.y0) * res / PX_PER_IN); + unsigned width = (unsigned) floor ((bbox.x1 - bbox.x0) * (res / PX_PER_IN)); + unsigned height =(unsigned) floor ((bbox.y1 - bbox.y0) * (res / PX_PER_IN)); + + double scale_x = (bbox.x1 - bbox.x0) / width; + double scale_y = (bbox.y1 - bbox.y0) / height; + // Find out if we have to run a filter gchar const *run = NULL; @@ -482,7 +484,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) shift_x = round (shift_x); shift_y = -round (-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone } - t = (Geom::Matrix)(Geom::Scale(1, -1) * (Geom::Matrix)(Geom::Translate (shift_x, shift_y)* eek.inverse())); + t = (Geom::Matrix)(Geom::Scale(scale_x, -scale_y) * (Geom::Matrix)(Geom::Translate (shift_x, shift_y)* eek.inverse())); //t = t * ((Geom::Matrix)ctx->getCurrentState()->transform).inverse(); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 94976da27..711e691f0 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -27,6 +27,7 @@ #include #include #include +#include "unit-constants.h" #include "libnr/nr-matrix-translate-ops.h" #include "libnr/nr-scale-ops.h" @@ -90,7 +91,7 @@ sp_export_jpg_file(SPDocument *doc, gchar const *filename, GdkPixbuf* sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, double x0, double y0, double x1, double y1, - unsigned width, unsigned height, double /*xdpi*/, double /*ydpi*/, + unsigned width, unsigned height, double xdpi, double ydpi, unsigned long bgcolor, GSList *items_only) @@ -108,16 +109,13 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, double zoom_scale = 1.0; double padding = 1.0; - width = (int)ceil(screen[Geom::X].extent() * zoom_scale * padding); - height = (int)ceil(screen[Geom::Y].extent() * zoom_scale * padding); - Geom::Point origin(screen.min()[Geom::X], sp_document_height(doc) - screen[Geom::Y].extent() - screen.min()[Geom::Y]); origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); - Geom::Scale scale(zoom_scale, zoom_scale); + Geom::Scale scale( (xdpi / PX_PER_IN), (ydpi / PX_PER_IN)); Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */