diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index b2306d2c..9c425506 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -109,26 +109,6 @@ vips_foreign_load_svg_dispose( GObject *gobject ) dispose( gobject ); } -static int -vips_foreign_load_svg_build( VipsObject *object ) -{ - VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) object; - - if( !vips_object_argument_isset( object, "scale" ) ) - svg->scale = svg->dpi / 72.0; - - /* librsvg defaults to 90 DPI, but vips defaults to 72. We need to - * adjust the scale down. - */ - svg->scale *= 72.0 / 90.0; - - if( VIPS_OBJECT_CLASS( vips_foreign_load_svg_parent_class )-> - build( object ) ) - return( -1 ); - - return( 0 ); -} - static VipsForeignFlags vips_foreign_load_svg_get_flags_filename( const char *filename ) { @@ -150,6 +130,7 @@ vips_foreign_load_svg_parse( VipsForeignLoadSvg *svg, RsvgDimensionData dimensions; double res; + rsvg_handle_set_dpi( svg->page, svg->dpi * svg->scale ); rsvg_handle_get_dimensions( svg->page, &dimensions ); /* We need pixels/mm for vips. @@ -157,7 +138,7 @@ vips_foreign_load_svg_parse( VipsForeignLoadSvg *svg, res = svg->dpi / 25.4; vips_image_init_fields( out, - dimensions.width * svg->scale, dimensions.height * svg->scale, + dimensions.width, dimensions.height, 4, VIPS_FORMAT_UCHAR, VIPS_CODING_NONE, VIPS_INTERPRETATION_sRGB, res, res ); @@ -201,9 +182,7 @@ vips_foreign_load_svg_generate( VipsRegion *or, cr = cairo_create( surface ); cairo_surface_destroy( surface ); - cairo_scale( cr, svg->scale, svg->scale ); - cairo_translate( cr, - -r->left / svg->scale, -r->top / svg->scale ); + cairo_translate( cr, -r->left, -r->top ); /* rsvg is single-threaded, but we don't need to lock since we're * running inside a non-threaded tilecache. @@ -279,7 +258,6 @@ vips_foreign_load_svg_class_init( VipsForeignLoadSvgClass *class ) object_class->nickname = "svgload"; object_class->description = _( "load SVG with rsvg" ); - object_class->build = vips_foreign_load_svg_build; load_class->get_flags_filename = vips_foreign_load_svg_get_flags_filename; @@ -564,8 +542,8 @@ vips_foreign_load_svg_buffer_init( VipsForeignLoadSvgBuffer *buffer ) * Render a SVG file into a VIPS image. Rendering uses the librsvg library * and should be fast. * - * Use @dpi to set the rendering resolution. The default is 72. Alternatively, - * you can scale the rendering from the default 1 point == 1 pixel by @scale. + * Use @dpi to set the rendering resolution. The default is 72. You can also + * scale the rendering by @scale. * * This function only reads the image header and does not render any pixel * data. Rendering occurs when pixels are accessed. diff --git a/test/images/blankpage.svg.png b/test/images/blankpage.svg.png index b206d027..01e4e739 100644 Binary files a/test/images/blankpage.svg.png and b/test/images/blankpage.svg.png differ