@@ -136,6 +136,7 @@ of small previews is displayed, making it easy to choose an image to open. | |||||
(also with Ctrl-arrow keys) | (also with Ctrl-arrow keys) | ||||
<,> Rotate image (counter-)clockwise by 90 degrees | <,> Rotate image (counter-)clockwise by 90 degrees | ||||
? Rotate image by 180 degrees | |||||
\,| Flip image horizontally/vertically | \,| Flip image horizontally/vertically | ||||
a Toggle anti-aliasing | a Toggle anti-aliasing | ||||
@@ -397,14 +397,17 @@ bool i_fit_to_img(arg_t a) | |||||
bool i_rotate(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 (mode == MODE_IMAGE) { | ||||
if (dir == DIR_LEFT) { | if (rot == ROTATE_90) { | ||||
img_rotate_left(&img); | img_rotate(&img, 1); | ||||
return true; | |||||
} else if (rot == ROTATE_270) { | |||||
img_rotate(&img, 3); | |||||
return true; | return true; | ||||
} else if (dir == DIR_RIGHT) { | } else if (rot == ROTATE_180) { | ||||
img_rotate_right(&img); | img_rotate(&img, 2); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -114,8 +114,9 @@ static const keymap_t keys[] = { | |||||
{ false, XK_E, i_fit_to_win, (arg_t) SCALE_HEIGHT }, | { false, XK_E, i_fit_to_win, (arg_t) SCALE_HEIGHT }, | ||||
{ false, XK_W, i_fit_to_img, (arg_t) None }, | { false, XK_W, i_fit_to_img, (arg_t) None }, | ||||
{ false, XK_less, i_rotate, (arg_t) DIR_LEFT }, | { false, XK_less, i_rotate, (arg_t) ROTATE_270 }, | ||||
{ false, XK_greater, i_rotate, (arg_t) DIR_RIGHT }, | { 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_backslash, i_flip, (arg_t) FLIP_HORIZONTAL }, | ||||
{ false, XK_bar, i_flip, (arg_t) FLIP_VERTICAL }, | { false, XK_bar, i_flip, (arg_t) FLIP_VERTICAL }, | ||||
@@ -131,10 +132,14 @@ static const keymap_t keys[] = { | |||||
"mogrify -rotate -90 \"$SXIV_IMG\"" }, | "mogrify -rotate -90 \"$SXIV_IMG\"" }, | ||||
{ true, XK_greater, it_shell_cmd, (arg_t) \ | { true, XK_greater, it_shell_cmd, (arg_t) \ | ||||
"mogrify -rotate +90 \"$SXIV_IMG\"" }, | "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) \ | { true, XK_comma, it_shell_cmd, (arg_t) \ | ||||
"jpegtran -rotate 270 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" }, | "jpegtran -rotate 270 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" }, | ||||
{ true, XK_period, it_shell_cmd, (arg_t) \ | { true, XK_period, it_shell_cmd, (arg_t) \ | ||||
"jpegtran -rotate 90 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" }, | "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: */ | /* mouse button mappings for image mode: */ | ||||
@@ -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; | oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom; | ||||
imlib_context_set_image(img->im); | imlib_context_set_image(img->im); | ||||
/* rotates by `90 * d` degrees in the clockwise direction */ | |||||
imlib_image_orientate(d); | imlib_image_orientate(d); | ||||
img->x = oy + (win->w - win->h) / 2; | if (d == 1 || d == 3) { | ||||
img->y = ox + (win->h - win->w) / 2; | img->x = oy + (win->w - win->h) / 2; | ||||
img->y = ox + (win->h - win->w) / 2; | |||||
tmp = img->w; | tmp = img->w; | ||||
img->w = img->h; | img->w = img->h; | ||||
img->h = tmp; | img->h = tmp; | ||||
img->checkpan = true; | |||||
} | |||||
img->checkpan = true; | |||||
img->dirty = 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) | void img_flip(img_t *img, flipdir_t d) | ||||
{ | { | ||||
if (img == NULL || img->im == NULL) | if (img == NULL || img->im == NULL) | ||||
@@ -77,9 +77,6 @@ bool img_pan(img_t*, direction_t, int); | |||||
bool img_pan_edge(img_t*, direction_t); | bool img_pan_edge(img_t*, direction_t); | ||||
void img_rotate(img_t*, int); | 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_flip(img_t*, flipdir_t); | ||||
void img_toggle_antialias(img_t*); | void img_toggle_antialias(img_t*); | ||||
@@ -261,6 +261,9 @@ Rotate image counter-clockwise by 90 degrees. | |||||
.TP | .TP | ||||
.B > | .B > | ||||
Rotate image clockwise by 90 degrees. | Rotate image clockwise by 90 degrees. | ||||
.TP | |||||
.B ? | |||||
Rotate image by 180 degrees. | |||||
.SS Flip | .SS Flip | ||||
.TP | .TP | ||||
.B \\\\ | .B \\\\ | ||||
@@ -38,6 +38,12 @@ typedef enum { | |||||
DIR_DOWN | DIR_DOWN | ||||
} direction_t; | } direction_t; | ||||
typedef enum { | |||||
ROTATE_90, | |||||
ROTATE_270, | |||||
ROTATE_180 | |||||
} rotate_t; | |||||
typedef enum { | typedef enum { | ||||
FLIP_HORIZONTAL, | FLIP_HORIZONTAL, | ||||
FLIP_VERTICAL | FLIP_VERTICAL | ||||