From 20d6cfe3f11756d9a8b6b70c3fbfe1dae08d42f6 Mon Sep 17 00:00:00 2001 From: cristy Date: Thu, 24 May 2012 00:39:22 +0000 Subject: [PATCH] --- coders/svg.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/coders/svg.c b/coders/svg.c index ea7319f14..ca20d1bd9 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -2851,8 +2851,8 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception) g_error_free(error); #if defined(MAGICKCORE_CAIRO_DELEGATE) rsvg_handle_get_dimensions(svg_handle,&dimension_info); - image->columns=dimension_info.width; - image->rows=dimension_info.height; + image->columns=image->resolution.x*dimension_info.width/72.0; + image->rows=image->resolution.y*dimension_info.height/72.0; pixels=(unsigned char *) NULL; #else pixel_info=rsvg_handle_get_pixbuf(svg_handle); @@ -2874,9 +2874,14 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception) } if (image_info->ping == MagickFalse) { + size_t + stride; + #if defined(MAGICKCORE_CAIRO_DELEGATE) - pixels=(unsigned char *) AcquireQuantumMemory(image->columns,4* - image->rows*sizeof(*pixels)); + stride=(size_t) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, + image->columns); + pixels=(unsigned char *) AcquireQuantumMemory(stride,image->rows* + sizeof(*pixels)); if (pixels == (unsigned char *) NULL) { g_object_unref(svg_handle); @@ -2886,7 +2891,7 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception) (void) SetImageBackgroundColor(image,exception); #if defined(MAGICKCORE_CAIRO_DELEGATE) cairo_surface=cairo_image_surface_create_for_data(pixels, - CAIRO_FORMAT_ARGB32,image->columns,image->rows,4*image->columns); + CAIRO_FORMAT_ARGB32,image->columns,image->rows,stride); if (cairo_surface == (cairo_surface_t *) NULL) { pixels=(unsigned char *) RelinquishMagickMemory(pixels); @@ -2897,6 +2902,8 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception) cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR); cairo_paint(cairo_image); cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER); + cairo_scale(cairo_image,image->resolution.x/72.0,image->resolution.y/ + 72.0); rsvg_handle_render_cairo(svg_handle,cairo_image); cairo_destroy(cairo_image); cairo_surface_destroy(cairo_surface); -- 2.40.0