Commit 4e20a8ce authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add option to set image background to white or black

parent e9ec78c5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -280,6 +280,10 @@ when images are scaled.
.B -N, --no-menus
Don't load or show any menus.
.TP 5
.B -B, --image-bg STYLE
Use STYLE as background for transparent image parts and the like.
Accepted values: white, black, default.
.TP 5
.B -1, --next-button B
Use button B to advance to the next image in slideshow
mode (defaults to 1, usually the left button).
+9 −1
Original line number Diff line number Diff line
@@ -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"
+1 −0
Original line number Diff line number Diff line
@@ -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;
+19 −12
Original line number Diff line number Diff line
@@ -627,6 +627,11 @@ feh_create_checks(void)
      eprintf
        ("Unable to create a teeny weeny imlib image. I detect problems");

    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) {
@@ -641,6 +646,8 @@ feh_create_checks(void)
            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);