From 7e51c35801f9921685c3acf0d1d17d9370ae4d59 Mon Sep 17 00:00:00 2001 From: Bastien Dejean Date: Sun, 23 Jun 2013 16:02:26 +0200 Subject: Handle 180 degrees image rotation --- image.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'image.c') diff --git a/image.c b/image.c index 3230880..b2ac293 100644 --- a/image.c +++ b/image.c @@ -663,29 +663,22 @@ void img_rotate(img_t *img, int d) oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom; imlib_context_set_image(img->im); + /* rotates by `90 * d` degrees in the clockwise direction */ imlib_image_orientate(d); - img->x = oy + (win->w - win->h) / 2; - img->y = ox + (win->h - win->w) / 2; + if (d == 1 || d == 3) { + img->x = oy + (win->w - win->h) / 2; + img->y = ox + (win->h - win->w) / 2; - tmp = img->w; - img->w = img->h; - img->h = tmp; + tmp = img->w; + img->w = img->h; + img->h = tmp; + img->checkpan = true; + } - img->checkpan = true; img->dirty = true; } -void img_rotate_left(img_t *img) -{ - img_rotate(img, 3); -} - -void img_rotate_right(img_t *img) -{ - img_rotate(img, 1); -} - void img_flip(img_t *img, flipdir_t d) { if (img == NULL || img->im == NULL) -- cgit v1.2.3