X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=example.c;fp=example.c;h=d0b0af074c7251fd4693898d8d8ce2d66c4b5eb4;hb=e24b4ba6c8887542d0e323cd7aeb977dd11fb9be;hp=7c69182f1e0e914aa84b1e2b22ab97ffe0f96fc1;hpb=64e09f16a76b3bc808bf1fe224f6efeb8c7963d1;p=libsvgtiny-pixbuf.git diff --git a/example.c b/example.c index 7c69182..d0b0af0 100644 --- a/example.c +++ b/example.c @@ -284,18 +284,21 @@ int main(int argc, char** argv) { return 1; } - /* We're using the diagram width and height and not the viewport - * width/height for the image. This has the potential to create an - * image with a different size and aspect ratio than the viewport, - * but since our viewport is entirely made-up... I don't know. This - * relies on libsvgtiny being good at scaling/stretching/etc an SVG - * that may only have partial width/height/viewBox information. + /* We're using the viewport width and height and not the diagram + * width/height for the image. The diagram can be of a different + * size and aspect ratio than the viewport, and our main use case is + * for icons that are generally square and reasonably sized. If the + * diagram is "small," then we want to scale it up until it fits + * nicely in the viewport before rendering it. That's as opposed to + * rendering the image small, and letting GDK scale it up. Of course + * this reasoning makes the assumption that the viewport is usually + * larger than the diagram. */ pb = gdk_pixbuf_get_from_surface(cairo_get_target(cr), 0, 0, - diagram->width, - diagram->height); + VIEWPORT_WIDTH, + VIEWPORT_HEIGHT); if (pb) { @@ -324,18 +327,22 @@ static GdkPixbuf* gdk_pixbuf_from_svg_file_stream(FILE *fp, GError **error) { return NULL; } - /* We're using the diagram width and height and not the viewport - * width/height for the image. This has the potential to create an - * image with a different size and aspect ratio than the viewport, - * but since our viewport is entirely made-up... I don't know. This - * relies on libsvgtiny being good at scaling/stretching/etc an SVG - * that may only have partial width/height/viewBox information. - */ + + /* We're using the viewport width and height and not the diagram + * width/height for the image. The diagram can be of a different + * size and aspect ratio than the viewport, and our main use case is + * for icons that are generally square and reasonably sized. If the + * diagram is "small," then we want to scale it up until it fits + * nicely in the viewport before rendering it. That's as opposed to + * rendering the image small, and letting GDK scale it up. Of course + * this reasoning makes the assumption that the viewport is usually + * larger than the diagram. + */ pb = gdk_pixbuf_get_from_surface(cairo_get_target(cr), 0, 0, - diagram->width, - diagram->height); + VIEWPORT_WIDTH, + VIEWPORT_HEIGHT); if (!pb) {