]> gitweb.michael.orlitzky.com - libsvgtiny-pixbuf.git/commitdiff
example.c: go back to viewport width/height.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 4 Aug 2023 13:12:00 +0000 (09:12 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 4 Aug 2023 13:12:00 +0000 (09:12 -0400)
example.c

index 7c69182f1e0e914aa84b1e2b22ab97ffe0f96fc1..d0b0af074c7251fd4693898d8d8ce2d66c4b5eb4 100644 (file)
--- 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) {