Krolyxon
Commit 26a624a

Branches

Refs →

nsxiv26a624a

Added options for anti-alias & alpha layer coloring to config.def.h

Also removed now obsolete -p command line option; fixes issue #98
Author
Bert Münnich
Date
2013-08-22 12:59 +0200
Parent
fb6e4bd
Commit
26a624a543f2e723550996d76d90ccbb7b954aeb

+23 −15

8 files changed

  1. M README.md +0 −1
  2. M commands.c +3 −1
  3. M config.def.h +13 −0
  4. M image.c +3 −2
  5. M options.c +2 −6
  6. M options.h +0 −1
  7. M sxiv.1 +0 −3
  8. M thumbs.c +2 −1
M README.md View
@@ -80,7 +80,6 @@ of small previews is displayed, making it easy to choose an image to open.
8080 -n NUM Start at picture NUM
8181 -N NAME Set X window resource name to NAME
8282 -o Write list of marked files to stdout when quitting
83− -p Pixelize, i.e. turn off image anti-aliasing
8483 -q Be quiet, disable warnings
8584 -r Search given directories recursively for images
8685 -s Scale all images to fit into window
M commands.c View
@@ -74,8 +74,10 @@ bool it_quit(arg_t a)
7474 bool it_switch_mode(arg_t a)
7575 {
7676 if (mode == MODE_IMAGE) {
77− if (tns.thumbs == NULL)
77+ if (tns.thumbs == NULL) {
7878 tns_init(&tns, filecnt, &win);
79+ tns.alpha = img.alpha;
80+ }
7981 img_close(&img, false);
8082 reset_timeout(reset_cursor);
8183 tns.sel = fileidx;
M config.def.h View
@@ -52,6 +52,19 @@ enum {
5252 /* default dimension of thumbnails (width == height): */
5353 enum { THUMB_SIZE = 60 };
5454
55+#endif
56+#ifdef _RENDER_CONFIG
57+
58+/* if false, pixelate images at zoom level != 100%,
59+ * toggled with 'a' key binding
60+ */
61+static const bool RENDER_ANTI_ALIAS = true;
62+
63+/* if true, use white background for alpha layer,
64+ * toggled with 'A' key binding
65+ */
66+static const bool RENDER_WHITE_ALPHA = false;
67+
5568 #endif
5669 #ifdef _MAPPINGS_CONFIG
5770
M image.c View
@@ -18,6 +18,7 @@
1818
1919 #define _POSIX_C_SOURCE 200112L
2020 #define _IMAGE_CONFIG
21+#define _RENDER_CONFIG
2122
2223 #include <stdlib.h>
2324 #include <string.h>
@@ -62,8 +63,8 @@ void img_init(img_t *img, win_t *win)
6263 img->zoom = MIN(img->zoom, zoom_max);
6364 img->checkpan = false;
6465 img->dirty = false;
65− img->aa = options->aa;
66− img->alpha = true;
66+ img->aa = RENDER_ANTI_ALIAS;
67+ img->alpha = !RENDER_WHITE_ALPHA;
6768 img->multi.cap = img->multi.cnt = 0;
6869 img->multi.animate = false;
6970 }
M options.c View
@@ -33,7 +33,7 @@ const options_t *options = (const options_t*) &_options;
3333
3434 void print_usage(void)
3535 {
36− printf("usage: sxiv [-bcdFfhiopqrstvZ] [-g GEOMETRY] [-n NUM] "
36+ printf("usage: sxiv [-bcdFfhioqrstvZ] [-g GEOMETRY] [-n NUM] "
3737 "[-N name] [-z ZOOM] FILES...\n");
3838 }
3939
@@ -53,7 +53,6 @@ void parse_options(int argc, char **argv)
5353
5454 _options.scalemode = SCALE_MODE;
5555 _options.zoom = 1.0;
56− _options.aa = true;
5756
5857 _options.fixed_win = false;
5958 _options.fullscreen = false;
@@ -65,7 +64,7 @@ void parse_options(int argc, char **argv)
6564 _options.thumb_mode = false;
6665 _options.clean_cache = false;
6766
68− while ((opt = getopt(argc, argv, "bcdFfg:hin:N:opqrstvZz:")) != -1) {
67+ while ((opt = getopt(argc, argv, "bcdFfg:hin:N:oqrstvZz:")) != -1) {
6968 switch (opt) {
7069 case '?':
7170 print_usage();
@@ -109,9 +108,6 @@ void parse_options(int argc, char **argv)
109108 case 'o':
110109 _options.to_stdout = true;
111110 break;
112− case 'p':
113− _options.aa = false;
114− break;
115111 case 'q':
116112 _options.quiet = true;
117113 break;
M options.h View
@@ -34,7 +34,6 @@ typedef struct {
3434 /* image: */
3535 scalemode_t scalemode;
3636 float zoom;
37− bool aa;
3837
3938 /* window: */
4039 bool fixed_win;
M sxiv.1 View
@@ -67,9 +67,6 @@ with
6767 .I \-i
6868 sxiv can be used as a visual filter/pipe.
6969 .TP
70−.B \-p
71−Pixelize images, i.e. turn off anti-aliasing.
72−.TP
7370 .B \-q
7471 Be quiet, disable warnings to standard error stream.
7572 .TP
M thumbs.c View
@@ -18,6 +18,7 @@
1818
1919 #define _POSIX_C_SOURCE 200112L
2020 #define _THUMBS_CONFIG
21+#define _RENDER_CONFIG
2122
2223 #include <stdlib.h>
2324 #include <string.h>
@@ -177,7 +178,7 @@ void tns_init(tns_t *tns, int cnt, win_t *win)
177178 tns->cap = cnt;
178179 tns->cnt = tns->first = tns->sel = 0;
179180 tns->win = win;
180− tns->alpha = true;
181+ tns->alpha = !RENDER_WHITE_ALPHA;
181182 tns->dirty = false;
182183
183184 if ((homedir = getenv("HOME")) != NULL) {