Krolyxon
Commit 7834dee

Branches

Refs →

nsxiv7834dee

Added a key-mapping for toggle anti-aliasing

Author
Bert
Date
2011-01-26 14:59 +0100
Parent
2bedd22
Commit
7834dee6e726df88e82ddc5e4c015023a50ba109

+28 −2

5 files changed

  1. M README.md +1 −0
  2. M image.c +14 −1
  3. M image.h +3 −0
  4. M main.c +6 −1
  5. M sxiv.1 +4 −0
M README.md View
@@ -45,3 +45,4 @@ Use the following keys to control sxiv:
4545 <,> Rotate image (counter-)clockwise by 90 degrees
4646 f Toggle fullscreen mode (requires an EWMH/NetWM compliant
4747 window manager)
48+ a Toggle anti-aliasing
M image.c View
@@ -33,8 +33,10 @@ void img_init(img_t *img, win_t *win) {
3333 zoom_min = zoom_levels[0] / 100.0;
3434 zoom_max = zoom_levels[zl_cnt - 1] / 100.0;
3535
36− if (img)
36+ if (img) {
3737 img->zoom = 1.0;
38+ img->aa = 1;
39+ }
3840
3941 if (win) {
4042 imlib_context_set_display(win->env.dpy);
@@ -63,6 +65,7 @@ int img_load(img_t *img, const char *filename) {
6365 }
6466
6567 imlib_context_set_image(im);
68+ imlib_context_set_anti_alias(img->aa);
6669
6770 img->re = 0;
6871 img->checkpan = 0;
@@ -272,3 +275,13 @@ int img_rotate_left(img_t *img, win_t *win) {
272275 int img_rotate_right(img_t *img, win_t *win) {
273276 return img_rotate(img, win, 1);
274277 }
278+
279+int img_toggle_antialias(img_t *img) {
280+ if (!img)
281+ return 0;
282+
283+ img->aa ^= 1;
284+ imlib_context_set_anti_alias(img->aa);
285+
286+ return 1;
287+}
M image.h View
@@ -39,6 +39,7 @@ typedef struct img_s {
3939 unsigned char re;
4040 unsigned char checkpan;
4141 unsigned char zoomed;
42+ unsigned char aa;
4243 int x;
4344 int y;
4445 int w;
@@ -59,4 +60,6 @@ int img_pan(img_t*, win_t*, pandir_t);
5960 int img_rotate_left(img_t*, win_t*);
6061 int img_rotate_right(img_t*, win_t*);
6162
63+int img_toggle_antialias(img_t*);
64+
6265 #endif /* IMAGE_H */
M main.c View
@@ -227,10 +227,15 @@ void on_keypress(XEvent *ev) {
227227 changed = img_rotate_right(&img, &win);
228228 break;
229229
230− /* Control window */
230+ /* control window */
231231 case 'f':
232232 win_toggle_fullscreen(&win);
233233 break;
234+
235+ /* miscellaneous */
236+ case 'a':
237+ changed = img_toggle_antialias(&img);
238+ break;
234239 }
235240
236241 if (changed) {
M sxiv.1 View
@@ -76,6 +76,10 @@ Rotate image clockwise by 90 degrees.
7676 .TP
7777 .B f
7878 Toggle fullscreen mode.
79+.SS Miscellaneous
80+.TP
81+.B a
82+Toggle anti-aliasing.
7983 .SH AUTHORS
8084 .TP
8185 Bert Muennich <ber.t at gmx.com>