diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-07-13 22:21:37 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-07-13 22:21:37 +0000 |
| commit | 0d6be77f2af241e47d0df3f19619db85ca8127e7 (patch) | |
| tree | 510d535eb41530772c79218ece39023d85d42c93 /src/extension/internal/cairo-renderer.cpp | |
| parent | Fix crashes during offscreen rendering, part 1 (diff) | |
| parent | Fix crashes in print preview (diff) | |
| download | inkscape-0d6be77f2af241e47d0df3f19619db85ca8127e7.tar.gz inkscape-0d6be77f2af241e47d0df3f19619db85ca8127e7.zip | |
Merge from trunk to pull in fix for LP #806105
(bzr r10347.1.13)
Diffstat (limited to 'src/extension/internal/cairo-renderer.cpp')
| -rw-r--r-- | src/extension/internal/cairo-renderer.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index bbafd7e94..1e550f7d1 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -41,6 +41,7 @@ #include "display/nr-arena-group.h" #include "display/curve.h" #include "display/canvas-bpath.h" +#include "display/cairo-utils.h" #include "sp-item.h" #include "sp-item-group.h" #include "style.h" @@ -345,18 +346,15 @@ static void sp_flowtext_render(SPItem *item, CairoRenderContext *ctx) static void sp_image_render(SPItem *item, CairoRenderContext *ctx) { SPImage *image; - guchar *px; - int w, h, rs; + int w, h; image = SP_IMAGE (item); if (!image->pixbuf) return; if ((image->width.computed <= 0.0) || (image->height.computed <= 0.0)) return; - px = gdk_pixbuf_get_pixels (image->pixbuf); w = gdk_pixbuf_get_width (image->pixbuf); h = gdk_pixbuf_get_height (image->pixbuf); - rs = gdk_pixbuf_get_rowstride (image->pixbuf); double x = image->x.computed; double y = image->y.computed; @@ -376,7 +374,7 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) Geom::Scale s(width / (double)w, height / (double)h); Geom::Affine t(s * tp); - ctx->renderImage (px, w, h, rs, &t, item->style); + ctx->renderImage (image->pixbuf, &t, item->style); } static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) @@ -477,9 +475,11 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } // The width and height of the bitmap in pixels - unsigned width = (unsigned) floor ((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN)); - unsigned height =(unsigned) floor ((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN)); - + unsigned width = ceil((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN)); + unsigned height = ceil((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN)); + + if (width == 0 || height == 0) return; + // Scale to exactly fit integer bitmap inside bounding box double scale_x = (bbox->max()[Geom::X] - bbox->min()[Geom::X]) / width; double scale_y = (bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) / height; @@ -516,11 +516,9 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) if (pb) { TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL )); - unsigned char *px = gdk_pixbuf_get_pixels (pb); - unsigned int w = gdk_pixbuf_get_width(pb); - unsigned int h = gdk_pixbuf_get_height(pb); - unsigned int rs = gdk_pixbuf_get_rowstride(pb); - ctx->renderImage(px, w, h, rs, &t, item->style); + // TODO this is stupid - we just converted to pixbuf format when generating the bitmap! + convert_pixbuf_normal_to_argb32(pb); + ctx->renderImage(pb, &t, item->style); gdk_pixbuf_unref(pb); pb = 0; } |
