]> git.mdlowis.com Git - proto/labwc.git/commitdiff
img: fix scaling for rendering large image in non-square rectangle
authortokyo4j <hrak1529@gmail.com>
Tue, 24 Dec 2024 04:39:25 +0000 (13:39 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 28 Dec 2024 23:06:38 +0000 (23:06 +0000)
16dbdc6 caused a regression that the vscode icon (1024x1024) in the
titlebar is cut off with following configuraion:

  window.button.width: 26
  window.button.height: 16

src/img/img.c

index 241c911c3c78594c10e3ddd09b68503ceb73612e..ccb7cdccbffe1f9028dd301cb6605a4889858191 100644 (file)
@@ -138,9 +138,9 @@ render_cairo_surface(cairo_surface_t *surface, int width, int height,
                .height = height - 2 * padding,
        };
 
-       struct wlr_box src_box = box_fit_within(src_w, src_h, &container);
-       double scene_scale = MIN(1.0, (double_t)container.width / (double)src_w);
-       cairo_translate(cairo, src_box.x, src_box.y);
+       struct wlr_box dst_box = box_fit_within(src_w, src_h, &container);
+       double scene_scale = (double)dst_box.width / (double)src_w;
+       cairo_translate(cairo, dst_box.x, dst_box.y);
        cairo_scale(cairo, scene_scale, scene_scale);
        cairo_set_source_surface(cairo, surface, 0, 0);
        cairo_pattern_set_filter(cairo_get_source(cairo), CAIRO_FILTER_GOOD);