Enlightenment CVS committal Author : raster Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/modules/loaders/svg Modified Files: evas_image_load_svg.c Log Message: added the ability to set load scaledown, dpi or load size - the svg loader uses these to know what to render and how (or has defaults if these are not set) =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/loaders/svg/evas_image_load_svg.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- evas_image_load_svg.c 17 Aug 2006 23:52:41 -0000 1.3 +++ evas_image_load_svg.c 18 Aug 2006 14:45:26 -0000 1.4 @@ -44,6 +44,7 @@ RsvgHandle *rsvg; RsvgDimensionData dim; + int w, h; if (!file) return 0; @@ -70,11 +71,37 @@ return 0; } } - - rsvg_handle_set_dpi_x_y(rsvg, 90, 90); + rsvg_handle_get_dimensions(rsvg, &dim); - im->image->w = dim.width; - im->image->h = dim.height; + w = dim.width; + h = dim.height; + if (im->load_opts.scale_down_by > 1) + { + w /= im->load_opts.scale_down_by; + h /= im->load_opts.scale_down_by; + } + else if (im->load_opts.dpi > 0.0) + { + w = (w * im->load_opts.dpi) / 90.0; + h = (h * im->load_opts.dpi) / 90.0; + } + else if ((im->load_opts.w > 0) && + (im->load_opts.h > 0)) + { + int w2, h2; + + w2 = im->load_opts.w; + h2 = (im->load_opts.w * h) / w; + if (h2 > im->load_opts.h) + { + h2 = im->load_opts.h; + w2 = (im->load_opts.h * w) / h; + } + } + if (w < 1) w = 1; + if (h < 1) h = 1; + im->image->w = w; + im->image->h = h; im->flags |= RGBA_IMAGE_HAS_ALPHA; rsvg_handle_free(rsvg); chdir(pcwd); @@ -114,10 +141,34 @@ return 0; } - rsvg_handle_set_dpi_x_y(rsvg, 90, 90); rsvg_handle_get_dimensions(rsvg, &dim); w = dim.width; h = dim.height; + if (im->load_opts.scale_down_by > 1) + { + w /= im->load_opts.scale_down_by; + h /= im->load_opts.scale_down_by; + } + else if (im->load_opts.dpi > 0.0) + { + w = (w * im->load_opts.dpi) / 90.0; + h = (h * im->load_opts.dpi) / 90.0; + } + else if ((im->load_opts.w > 0) && + (im->load_opts.h > 0)) + { + int w2, h2; + + w2 = im->load_opts.w; + h2 = (im->load_opts.w * h) / w; + if (h2 > im->load_opts.h) + { + h2 = im->load_opts.h; + w2 = (im->load_opts.h * w) / h; + } + } + if (w < 1) w = 1; + if (h < 1) h = 1; im->image->w = w; im->image->h = h; im->flags |= RGBA_IMAGE_HAS_ALPHA; @@ -154,6 +205,7 @@ return 0; } + cairo_scale(cr, (double)im->image->w / dim.em, (double)im->image->h / dim.ex); rsvg_handle_render_cairo(rsvg, cr); cairo_surface_destroy(surface); /* need to check if this is required... */ ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs