summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-02-06 21:59:25 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-02-06 21:59:25 +0100
commit4e20a8cea66e707846f78f7cf55806b131c71a61 (patch)
treed778eef0c5837c5cb6769251c999202b25fafa84 /src
parente9ec78c5e0c7030433b89519a1a000f3a70d0787 (diff)
downloadfeh-4e20a8cea66e707846f78f7cf55806b131c71a61.zip
Add option to set image background to white or black
Diffstat (limited to 'src')
-rw-r--r--src/options.c10
-rw-r--r--src/options.h1
-rw-r--r--src/winwidget.c31
3 files changed, 29 insertions, 13 deletions
diff --git a/src/options.c b/src/options.c
index 3dd3981..c41645f 100644
--- a/src/options.c
+++ b/src/options.c
@@ -55,6 +55,7 @@ init_parse_options(int argc, char **argv)
opt.thumb_h = 60;
opt.menu_font = estrdup(DEFAULT_MENU_FONT);
opt.font = estrdup(DEFAULT_FONT);
+ opt.image_bg = estrdup("default");
opt.menu_bg = estrdup(PREFIX "/share/feh/images/menubg_default.png");
opt.menu_style = estrdup(PREFIX "/share/feh/fonts/menu.style");
opt.menu_border = 4;
@@ -316,7 +317,7 @@ static void
feh_parse_option_array(int argc, char **argv)
{
static char stropts[] =
- "a:A:b:BcC:dD:e:E:f:Fg:GhH:iIj:klL:mM:nNo:O:pqQrR:sS:tT:uUvVwW:xXy:zZ1:2:4:56:78:90:.@:^:~:):|:_:+:";
+ "a:A:b:B:cC:dD:e:E:f:Fg:GhH:iIj:klL:mM:nNo:O:pqQrR:sS:tT:uUvVwW:xXy:zZ1:2:4:56:78:90:.@:^:~:):|:_:+:";
static struct option lopts[] = {
/* actions */
{"help", 0, 0, 'h'}, /* okay */
@@ -378,6 +379,7 @@ feh_parse_option_array(int argc, char **argv)
{"bg", 1, 0, 'b'},
{"fontpath", 1, 0, 'C'},
{"menu-bg", 1, 0, ')'},
+ {"image-bg", 1, 0, 'B'},
{"next-button", 1, 0, '1'},
{"zoom-button", 1, 0, '2'},
{"menu-button", 1, 0, '4'},
@@ -606,6 +608,10 @@ feh_parse_option_array(int argc, char **argv)
free(opt.menu_bg);
opt.menu_bg = estrdup(optarg);
break;
+ case 'B':
+ free(opt.image_bg);
+ opt.image_bg = estrdup(optarg);
+ break;
case 'D':
opt.slideshow_delay = atof(optarg);
break;
@@ -1002,6 +1008,8 @@ show_usage(void)
" --menu-border INT Specify number of pixels that define the menu\n"
" background's border. Borders are not stretched\n"
" when images are scaled.\n"
+" -B, --image-bg STYLE Set background for transparent images and the like.\n"
+" Accepted values: white, black, default\n"
" -N, --no-menus Don't load or show any menus.\n"
" -1, --next-button B Use button B to advance to the next image in any\n"
" mode (defaults to 1, usually the left button).\n"
diff --git a/src/options.h b/src/options.h
index 0101885..0c60c9b 100644
--- a/src/options.h
+++ b/src/options.h
@@ -85,6 +85,7 @@ struct __fehoptions
char *menu_font;
char *customlist;
char *menu_bg;
+ char *image_bg;
char *rcfile;
char *menu_style;
char *caption_path;
diff --git a/src/winwidget.c b/src/winwidget.c
index fe98e85..c494123 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -627,20 +627,27 @@ feh_create_checks(void)
eprintf
("Unable to create a teeny weeny imlib image. I detect problems");
- for (y = 0; y < 16; y += 8) {
- onoff = (y / 8) & 0x1;
- for (x = 0; x < 16; x += 8) {
- if (onoff)
- gib_imlib_image_fill_rectangle(checks, x, y, 8, 8, 144, 144, 144,
- 255);
- else
- gib_imlib_image_fill_rectangle(checks, x, y, 8, 8, 100, 100, 100,
- 255);
- onoff++;
- if (onoff == 2)
- onoff = 0;
+ if (strncmp(opt.image_bg, "white", 5) == 0)
+ gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 255, 255, 255, 255);
+ else if (strncmp(opt.image_bg, "black", 5) == 0)
+ gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 0, 0, 0, 255);
+ else {
+ for (y = 0; y < 16; y += 8) {
+ onoff = (y / 8) & 0x1;
+ for (x = 0; x < 16; x += 8) {
+ if (onoff)
+ gib_imlib_image_fill_rectangle(checks, x, y, 8, 8, 144, 144, 144,
+ 255);
+ else
+ gib_imlib_image_fill_rectangle(checks, x, y, 8, 8, 100, 100, 100,
+ 255);
+ onoff++;
+ if (onoff == 2)
+ onoff = 0;
+ }
}
}
+
checks_pmap = XCreatePixmap(disp, root, 16, 16, depth);
gib_imlib_render_image_on_drawable(checks_pmap, checks, 0, 0, 1, 0, 0);
gib_imlib_free_image_and_decache(checks);