瀏覽代碼

Handle 180 degrees image rotation

master
Bastien Dejean Bert Münnich 11 年之前
父節點
當前提交
7e51c35801
共有 7 個檔案被更改,包括 34 行新增26 行删除
  1. +1
    -0
      README.md
  2. +8
    -5
      commands.c
  3. +7
    -2
      config.def.h
  4. +9
    -16
      image.c
  5. +0
    -3
      image.h
  6. +3
    -0
      sxiv.1
  7. +6
    -0
      types.h

+ 1
- 0
README.md 查看文件

@@ -136,6 +136,7 @@ of small previews is displayed, making it easy to choose an image to open.
(also with Ctrl-arrow keys)

<,> Rotate image (counter-)clockwise by 90 degrees
? Rotate image by 180 degrees
\,| Flip image horizontally/vertically

a Toggle anti-aliasing


+ 8
- 5
commands.c 查看文件

@@ -397,14 +397,17 @@ bool i_fit_to_img(arg_t a)

bool i_rotate(arg_t a)
{
direction_t dir = (direction_t) a;
rotate_t rot = (rotate_t) a;

if (mode == MODE_IMAGE) {
if (dir == DIR_LEFT) {
img_rotate_left(&img);
if (rot == ROTATE_90) {
img_rotate(&img, 1);
return true;
} else if (rot == ROTATE_270) {
img_rotate(&img, 3);
return true;
} else if (dir == DIR_RIGHT) {
img_rotate_right(&img);
} else if (rot == ROTATE_180) {
img_rotate(&img, 2);
return true;
}
}


+ 7
- 2
config.def.h 查看文件

@@ -114,8 +114,9 @@ static const keymap_t keys[] = {
{ false, XK_E, i_fit_to_win, (arg_t) SCALE_HEIGHT },
{ false, XK_W, i_fit_to_img, (arg_t) None },

{ false, XK_less, i_rotate, (arg_t) DIR_LEFT },
{ false, XK_greater, i_rotate, (arg_t) DIR_RIGHT },
{ false, XK_less, i_rotate, (arg_t) ROTATE_270 },
{ false, XK_greater, i_rotate, (arg_t) ROTATE_90 },
{ false, XK_question, i_rotate, (arg_t) ROTATE_180 },

{ false, XK_backslash, i_flip, (arg_t) FLIP_HORIZONTAL },
{ false, XK_bar, i_flip, (arg_t) FLIP_VERTICAL },
@@ -131,10 +132,14 @@ static const keymap_t keys[] = {
"mogrify -rotate -90 \"$SXIV_IMG\"" },
{ true, XK_greater, it_shell_cmd, (arg_t) \
"mogrify -rotate +90 \"$SXIV_IMG\"" },
{ true, XK_question, it_shell_cmd, (arg_t) \
"mogrify -rotate 180 \"$SXIV_IMG\"" },
{ true, XK_comma, it_shell_cmd, (arg_t) \
"jpegtran -rotate 270 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },
{ true, XK_period, it_shell_cmd, (arg_t) \
"jpegtran -rotate 90 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },
{ true, XK_slash, it_shell_cmd, (arg_t) \
"jpegtran -rotate 180 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },
};

/* mouse button mappings for image mode: */


+ 9
- 16
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)


+ 0
- 3
image.h 查看文件

@@ -77,9 +77,6 @@ bool img_pan(img_t*, direction_t, int);
bool img_pan_edge(img_t*, direction_t);

void img_rotate(img_t*, int);
void img_rotate_left(img_t*);
void img_rotate_right(img_t*);

void img_flip(img_t*, flipdir_t);

void img_toggle_antialias(img_t*);


+ 3
- 0
sxiv.1 查看文件

@@ -261,6 +261,9 @@ Rotate image counter-clockwise by 90 degrees.
.TP
.B >
Rotate image clockwise by 90 degrees.
.TP
.B ?
Rotate image by 180 degrees.
.SS Flip
.TP
.B \\\\


+ 6
- 0
types.h 查看文件

@@ -38,6 +38,12 @@ typedef enum {
DIR_DOWN
} direction_t;

typedef enum {
ROTATE_90,
ROTATE_270,
ROTATE_180
} rotate_t;

typedef enum {
FLIP_HORIZONTAL,
FLIP_VERTICAL


||||||
x
 
000:0
Loading…
取消
儲存