diff options
author | Daniel Eklöf <daniel@ekloef.se> | 2023-10-26 16:32:50 +0200 |
---|---|---|
committer | Daniel Eklöf <daniel@ekloef.se> | 2023-10-26 16:32:50 +0200 |
commit | 423f7dc6990b1cb5afde95f8383c44b1a4dce16a (patch) | |
tree | ce22ea28126d73c68bc290505e8fee6a781a89c5 | |
parent | 61af8e87661b93cfefe77c083328fef962c4121d (diff) | |
parent | 8798bf08c1ae0d8c1334ea914c80ddaf322c9fb3 (diff) | |
download | wbg-423f7dc6990b1cb5afde95f8383c44b1a4dce16a.tar.gz |
Merge branch 'zoom'
Closes #6
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | main.c | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b1b71c..054403f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ ### Changed + +* Image is now zoomed, rather than stretched ([#6][6]). + +[6]: https://codeberg.org/dnkl/wbg/issues/6 + + ### Deprecated ### Removed ### Fixed @@ -91,8 +91,16 @@ render(struct output *output) double sx = (double)img_width / (width * scale); double sy = (double)img_height / (height * scale); + float s = sx > sy ? sy : sx; + sx = s; + sy = s; + + float tx = (img_width / sx - width) / 2 / sx; + float ty = (img_height / sy - height) / 2 / sy; + pixman_f_transform_t t; pixman_transform_t t2; + pixman_f_transform_init_translate(&t, tx, ty); pixman_f_transform_init_scale(&t, sx, sy); pixman_transform_from_pixman_f_transform(&t2, &t); pixman_image_set_transform(pix, &t2); |