aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-26 14:59:32 +0100
committerBert <ber.t@gmx.com>2011-01-26 14:59:32 +0100
commit7834dee6e726df88e82ddc5e4c015023a50ba109 (patch)
tree272cb49856d7089ac61a7e23abaa5700c6c8b8f0
parent2bedd223149e44b8d9ef9a6f2bf07b8a088aabe3 (diff)
Added a key-mapping for toggle anti-aliasing
-rw-r--r--README.md1
-rw-r--r--image.c15
-rw-r--r--image.h3
-rw-r--r--main.c7
-rw-r--r--sxiv.14
5 files changed, 28 insertions, 2 deletions
diff --git a/README.md b/README.md
index 2641561..fced5f8 100644
--- a/README.md
+++ b/README.md
@@ -45,3 +45,4 @@ Use the following keys to control sxiv:
<,> Rotate image (counter-)clockwise by 90 degrees
f Toggle fullscreen mode (requires an EWMH/NetWM compliant
window manager)
+ a Toggle anti-aliasing
diff --git a/image.c b/image.c
index beff925..fa2ad5d 100644
--- a/image.c
+++ b/image.c
@@ -33,8 +33,10 @@ void img_init(img_t *img, win_t *win) {
zoom_min = zoom_levels[0] / 100.0;
zoom_max = zoom_levels[zl_cnt - 1] / 100.0;
- if (img)
+ if (img) {
img->zoom = 1.0;
+ img->aa = 1;
+ }
if (win) {
imlib_context_set_display(win->env.dpy);
@@ -63,6 +65,7 @@ int img_load(img_t *img, const char *filename) {
}
imlib_context_set_image(im);
+ imlib_context_set_anti_alias(img->aa);
img->re = 0;
img->checkpan = 0;
@@ -272,3 +275,13 @@ int img_rotate_left(img_t *img, win_t *win) {
int img_rotate_right(img_t *img, win_t *win) {
return img_rotate(img, win, 1);
}
+
+int img_toggle_antialias(img_t *img) {
+ if (!img)
+ return 0;
+
+ img->aa ^= 1;
+ imlib_context_set_anti_alias(img->aa);
+
+ return 1;
+}
diff --git a/image.h b/image.h
index 55b825c..2284dd5 100644
--- a/image.h
+++ b/image.h
@@ -39,6 +39,7 @@ typedef struct img_s {
unsigned char re;
unsigned char checkpan;
unsigned char zoomed;
+ unsigned char aa;
int x;
int y;
int w;
@@ -59,4 +60,6 @@ int img_pan(img_t*, win_t*, pandir_t);
int img_rotate_left(img_t*, win_t*);
int img_rotate_right(img_t*, win_t*);
+int img_toggle_antialias(img_t*);
+
#endif /* IMAGE_H */
diff --git a/main.c b/main.c
index 039394c..53f206b 100644
--- a/main.c
+++ b/main.c
@@ -227,10 +227,15 @@ void on_keypress(XEvent *ev) {
changed = img_rotate_right(&img, &win);
break;
- /* Control window */
+ /* control window */
case 'f':
win_toggle_fullscreen(&win);
break;
+
+ /* miscellaneous */
+ case 'a':
+ changed = img_toggle_antialias(&img);
+ break;
}
if (changed) {
diff --git a/sxiv.1 b/sxiv.1
index b9a3b95..3299cb1 100644
--- a/sxiv.1
+++ b/sxiv.1
@@ -76,6 +76,10 @@ Rotate image clockwise by 90 degrees.
.TP
.B f
Toggle fullscreen mode.
+.SS Miscellaneous
+.TP
+.B a
+Toggle anti-aliasing.
.SH AUTHORS
.TP
Bert Muennich <ber.t at gmx.com>