mirror of
https://codeberg.org/nsxiv/nsxiv
synced 2024-10-31 09:20:19 +00:00
fix: image placement when rotating (#493)
When rotating a partially shown image (i.e. image size * zoom > window size) the image is panned to top or left (if `win->w` or `win->h` is greatest, respectively). Seems to be due to unsignedness of `win->[wh]`, when taking the difference between them in `img_rotate` either `img->[xy]` ends up being close to `UINT_MAX` and the image is panned to top or left edge. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/493 Reviewed-by: NRK <nrk@disroot.org> Co-authored-by: e5150 <e5150@noreply.codeberg.org> Co-committed-by: e5150 <e5150@noreply.codeberg.org>
This commit is contained in:
parent
437e060021
commit
a581cd6344
4
image.c
4
image.c
@ -676,8 +676,8 @@ void img_rotate(img_t *img, degree_t d)
|
|||||||
ox = d == DEGREE_90 ? img->x : img->win->w - img->x - img->w * img->zoom;
|
ox = d == DEGREE_90 ? img->x : img->win->w - img->x - img->w * img->zoom;
|
||||||
oy = d == DEGREE_270 ? img->y : img->win->h - img->y - img->h * img->zoom;
|
oy = d == DEGREE_270 ? img->y : img->win->h - img->y - img->h * img->zoom;
|
||||||
|
|
||||||
img->x = oy + (img->win->w - img->win->h) / 2;
|
img->x = oy + (int)(img->win->w - img->win->h) / 2;
|
||||||
img->y = ox + (img->win->h - img->win->w) / 2;
|
img->y = ox + (int)(img->win->h - img->win->w) / 2;
|
||||||
|
|
||||||
tmp = img->w;
|
tmp = img->w;
|
||||||
img->w = img->h;
|
img->w = img->h;
|
||||||
|
Loading…
Reference in New Issue
Block a user