Krolyxon
Commit 2c566c5

Branches

Refs →

nsxiv2c566c5

Add -A option to force framerate on animated images

Author
dwminer
Date
2016-11-27 02:54 -0500
Committer
dwminer · 2016-11-27 02:59 -0500
Parent
32b29e6
Commit
2c566c5320c11e9844f192bfcff2d1a869471415

+14 −2

4 files changed

  1. M image.c +2 −0
  2. M image.h +1 −0
  3. M options.c +10 −2
  4. M options.h +1 −0
M image.c View
@@ -68,6 +68,7 @@ void img_init(img_t *img, win_t *win)
6868 img->alpha = ALPHA_LAYER;
6969 img->multi.cap = img->multi.cnt = 0;
7070 img->multi.animate = options->animate;
71+ img->multi.framedelay = options->framerate > 0 ? 1000 / options->framerate : 0;
7172 img->multi.length = 0;
7273
7374 img->cmod = imlib_create_color_modifier();
@@ -263,6 +264,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
263264 img->multi.cap * sizeof(img_frame_t));
264265 }
265266 img->multi.frames[img->multi.cnt].im = im;
267+ delay = img->multi.framedelay > 0 ? img->multi.framedelay : delay;
266268 img->multi.frames[img->multi.cnt].delay = delay > 0 ? delay : DEF_GIF_DELAY;
267269 img->multi.length += img->multi.frames[img->multi.cnt].delay;
268270 img->multi.cnt++;
M image.h View
@@ -35,6 +35,7 @@ typedef struct {
3535 int cnt;
3636 int sel;
3737 bool animate;
38+ int framedelay;
3839 int length;
3940 } multi_img_t;
4041
M options.c View
@@ -32,7 +32,7 @@ const options_t *options = (const options_t*) &_options;
3232
3333 void print_usage(void)
3434 {
35− printf("usage: sxiv [-abcfhioqrtvZ] [-e WID] [-G GAMMA] [-g GEOMETRY] "
35+ printf("usage: sxiv [-abcfhioqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] [-g GEOMETRY] "
3636 "[-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n");
3737 }
3838
@@ -60,6 +60,7 @@ void parse_options(int argc, char **argv)
6060 _options.animate = false;
6161 _options.gamma = 0;
6262 _options.slideshow = 0;
63+ _options.framerate = 0;
6364
6465 _options.fullscreen = false;
6566 _options.embed = 0;
@@ -71,7 +72,7 @@ void parse_options(int argc, char **argv)
7172 _options.thumb_mode = false;
7273 _options.clean_cache = false;
7374
74− while ((opt = getopt(argc, argv, "abce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) {
75+ while ((opt = getopt(argc, argv, "aA:bce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) {
7576 switch (opt) {
7677 case '?':
7778 print_usage();
@@ -79,6 +80,13 @@ void parse_options(int argc, char **argv)
7980 case 'a':
8081 _options.animate = true;
8182 break;
83+ case 'A':
84+ _options.animate = true;
85+ n = strtol(optarg, &end, 0);
86+ if (*end != '\0' || n <= 0)
87+ error(EXIT_FAILURE, 0, "Invalid argument for option -A: %s", optarg);
88+ _options.framerate = n;
89+ break;
8290 case 'b':
8391 _options.hide_bar = true;
8492 break;
M options.h View
@@ -37,6 +37,7 @@ typedef struct {
3737 bool animate;
3838 int gamma;
3939 int slideshow;
40+ int framerate;
4041
4142 /* window: */
4243 bool fullscreen;