From: Michael Orlitzky Date: Fri, 4 Aug 2023 13:12:00 +0000 (-0400) Subject: example.c: go back to viewport width/height. X-Git-Tag: 0.0.1~44 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=e24b4ba6c8887542d0e323cd7aeb977dd11fb9be;p=libsvgtiny-pixbuf.git example.c: go back to viewport width/height. --- 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) {