Krolyxon
Commit 002c7e5

Branches

Refs →

nsxiv002c7e5

Second take at rotating & flipping multi-frame images; fixes issue #121

Author
Bert Münnich
Date
2014-01-09 20:32 +0100
Parent
48700aa
Commit
002c7e550bf7ebf7491fbaaa7c4f3710f871d76a

+26 −17

3 files changed

  1. M Makefile +1 −1
  2. M image.c +23 −14
  3. M types.h +2 −2
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20140108
1+VERSION = git-20140109
22
33 PREFIX = /usr/local
44 MANPREFIX = $(PREFIX)/share/man
M image.c View
@@ -100,21 +100,17 @@ void exif_auto_orientate(const fileinfo_t *file)
100100 case 2:
101101 imlib_image_flip_vertical();
102102 break;
103−
104103 case 3:
105104 imlib_image_orientate(2);
106105 break;
107−
108106 case 7:
109107 imlib_image_orientate(1);
110108 case 4:
111109 imlib_image_flip_horizontal();
112110 break;
113−
114111 case 6:
115112 imlib_image_orientate(1);
116113 break;
117−
118114 case 8:
119115 imlib_image_orientate(3);
120116 break;
@@ -688,7 +684,7 @@ bool img_pan_edge(img_t *img, direction_t dir)
688684
689685 void img_rotate(img_t *img, degree_t d)
690686 {
691− int ox, oy, tmp;
687+ int i, ox, oy, tmp;
692688
693689 if (img == NULL || img->im == NULL || img->win == NULL)
694690 return;
@@ -696,6 +692,12 @@ void img_rotate(img_t *img, degree_t d)
696692 imlib_context_set_image(img->im);
697693 imlib_image_orientate(d);
698694
695+ for (i = 0; i < img->multi.cnt; i++) {
696+ if (i != img->multi.sel) {
697+ imlib_context_set_image(img->multi.frames[i].im);
698+ imlib_image_orientate(d);
699+ }
700+ }
699701 if (d == DEGREE_90 || d == DEGREE_270) {
700702 ox = d == DEGREE_90 ? img->x : img->win->w - img->x - img->w * img->zoom;
701703 oy = d == DEGREE_270 ? img->y : img->win->h - img->y - img->h * img->zoom;
@@ -708,24 +710,31 @@ void img_rotate(img_t *img, degree_t d)
708710 img->h = tmp;
709711 img->checkpan = true;
710712 }
711−
712713 img->dirty = true;
713714 }
714715
715716 void img_flip(img_t *img, flipdir_t d)
716717 {
717− if (img == NULL || img->im == NULL)
718+ int i;
719+ void (*imlib_flip_op[3])(void) = {
720+ imlib_image_flip_horizontal,
721+ imlib_image_flip_vertical,
722+ imlib_image_flip_diagonal
723+ };
724+
725+ d = (d & (FLIP_HORIZONTAL | FLIP_VERTICAL)) - 1;
726+
727+ if (img == NULL || img->im == NULL || d < 0 || d >= ARRLEN(imlib_flip_op))
718728 return;
719729
720730 imlib_context_set_image(img->im);
731+ imlib_flip_op[d]();
721732
722− switch (d) {
723− case FLIP_HORIZONTAL:
724− imlib_image_flip_horizontal();
725− break;
726− case FLIP_VERTICAL:
727− imlib_image_flip_vertical();
728− break;
733+ for (i = 0; i < img->multi.cnt; i++) {
734+ if (i != img->multi.sel) {
735+ imlib_context_set_image(img->multi.frames[i].im);
736+ imlib_flip_op[d]();
737+ }
729738 }
730739 img->dirty = true;
731740 }
M types.h View
@@ -45,8 +45,8 @@ typedef enum {
4545 } degree_t;
4646
4747 typedef enum {
48− FLIP_HORIZONTAL,
49− FLIP_VERTICAL
48+ FLIP_HORIZONTAL = 1,
49+ FLIP_VERTICAL = 2
5050 } flipdir_t;
5151
5252 typedef enum {