aboutsummaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-27 01:48:00 +0100
committerBert <ber.t@gmx.com>2011-02-27 01:48:00 +0100
commit090ee5405b70d6dfa16a8ca3a691dbd556c41bdb (patch)
tree1536ab1f40eb2c87a84d430b26b8952b7aeb03f0 /image.c
parentdc68127ae54ae86459d92457c5ea1f08009f67ab (diff)
downloadnsxiv-090ee5405b70d6dfa16a8ca3a691dbd556c41bdb.tar.zst
Save rotated png-files with S-key
Diffstat (limited to 'image.c')
-rw-r--r--image.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/image.c b/image.c
index 5a69c20..45e0926 100644
--- a/image.c
+++ b/image.c
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <string.h>
#include <unistd.h>
#include "config.h"
@@ -28,6 +29,9 @@ int zl_cnt;
float zoom_min;
float zoom_max;
+const short ori_left[8] = { 8, 7, 6, 5, 2, 1, 4, 3 };
+const short ori_right[8] = { 6, 5, 8, 7, 4, 3, 2, 1 };
+
Imlib_Image *im_broken;
void img_init(img_t *img, win_t *win) {
@@ -90,8 +94,8 @@ int img_load(img_t *img, const char *filename) {
img->scalemode = SCALE_DOWN;
}
- img->re = 0;
- img->checkpan = 0;
+ img->ori = img->o_ori = 1;
+ img->re = img->checkpan = 0;
img->w = imlib_image_get_width();
img->h = imlib_image_get_height();
@@ -99,6 +103,25 @@ int img_load(img_t *img, const char *filename) {
return 1;
}
+int img_save(img_t *img) {
+ const char *fmt;
+
+ if (!img || !img->im)
+ return 0;
+
+ imlib_context_set_image(img->im);
+
+ if (img->ori != img->o_ori) {
+ fmt = imlib_image_format();
+ if (strcmp(fmt, "png") == 0) {
+ imlib_save_image(imlib_image_get_filename());
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
void img_close(img_t *img) {
if (img && img->im) {
imlib_context_set_image(img->im);
@@ -341,11 +364,17 @@ void img_rotate(img_t *img, win_t *win, int d) {
}
void img_rotate_left(img_t *img, win_t *win) {
- img_rotate(img, win, 3);
+ if (img) {
+ img_rotate(img, win, 3);
+ img->ori = ori_left[img->ori];
+ }
}
void img_rotate_right(img_t *img, win_t *win) {
- img_rotate(img, win, 1);
+ if (img) {
+ img_rotate(img, win, 1);
+ img->ori = ori_right[img->ori];
+ }
}
void img_toggle_antialias(img_t *img) {