浏览代码

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

master
Bert Münnich 10 年前
父节点
当前提交
002c7e550b
共有 3 个文件被更改,包括 26 次插入17 次删除
  1. +1
    -1
      Makefile
  2. +23
    -14
      image.c
  3. +2
    -2
      types.h

+ 1
- 1
Makefile 查看文件

@@ -1,4 +1,4 @@
VERSION = git-20140108
VERSION = git-20140109


PREFIX = /usr/local PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man MANPREFIX = $(PREFIX)/share/man


+ 23
- 14
image.c 查看文件

@@ -100,21 +100,17 @@ void exif_auto_orientate(const fileinfo_t *file)
case 2: case 2:
imlib_image_flip_vertical(); imlib_image_flip_vertical();
break; break;

case 3: case 3:
imlib_image_orientate(2); imlib_image_orientate(2);
break; break;

case 7: case 7:
imlib_image_orientate(1); imlib_image_orientate(1);
case 4: case 4:
imlib_image_flip_horizontal(); imlib_image_flip_horizontal();
break; break;

case 6: case 6:
imlib_image_orientate(1); imlib_image_orientate(1);
break; break;

case 8: case 8:
imlib_image_orientate(3); imlib_image_orientate(3);
break; break;
@@ -688,7 +684,7 @@ bool img_pan_edge(img_t *img, direction_t dir)


void img_rotate(img_t *img, degree_t d) void img_rotate(img_t *img, degree_t d)
{ {
int ox, oy, tmp;
int i, ox, oy, tmp;


if (img == NULL || img->im == NULL || img->win == NULL) if (img == NULL || img->im == NULL || img->win == NULL)
return; return;
@@ -696,6 +692,12 @@ void img_rotate(img_t *img, degree_t d)
imlib_context_set_image(img->im); imlib_context_set_image(img->im);
imlib_image_orientate(d); imlib_image_orientate(d);


for (i = 0; i < img->multi.cnt; i++) {
if (i != img->multi.sel) {
imlib_context_set_image(img->multi.frames[i].im);
imlib_image_orientate(d);
}
}
if (d == DEGREE_90 || d == DEGREE_270) { if (d == DEGREE_90 || d == DEGREE_270) {
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;
@@ -708,24 +710,31 @@ void img_rotate(img_t *img, degree_t d)
img->h = tmp; img->h = tmp;
img->checkpan = true; img->checkpan = true;
} }

img->dirty = true; img->dirty = true;
} }


void img_flip(img_t *img, flipdir_t d) void img_flip(img_t *img, flipdir_t d)
{ {
if (img == NULL || img->im == NULL)
int i;
void (*imlib_flip_op[3])(void) = {
imlib_image_flip_horizontal,
imlib_image_flip_vertical,
imlib_image_flip_diagonal
};

d = (d & (FLIP_HORIZONTAL | FLIP_VERTICAL)) - 1;

if (img == NULL || img->im == NULL || d < 0 || d >= ARRLEN(imlib_flip_op))
return; return;


imlib_context_set_image(img->im); imlib_context_set_image(img->im);
imlib_flip_op[d]();


switch (d) {
case FLIP_HORIZONTAL:
imlib_image_flip_horizontal();
break;
case FLIP_VERTICAL:
imlib_image_flip_vertical();
break;
for (i = 0; i < img->multi.cnt; i++) {
if (i != img->multi.sel) {
imlib_context_set_image(img->multi.frames[i].im);
imlib_flip_op[d]();
}
} }
img->dirty = true; img->dirty = true;
} }


+ 2
- 2
types.h 查看文件

@@ -45,8 +45,8 @@ typedef enum {
} degree_t; } degree_t;


typedef enum { typedef enum {
FLIP_HORIZONTAL,
FLIP_VERTICAL
FLIP_HORIZONTAL = 1,
FLIP_VERTICAL = 2
} flipdir_t; } flipdir_t;


typedef enum { typedef enum {


正在加载...
取消
保存