Add -A option to force framerate on animated images
This commit is contained in:
parent
32b29e61c1
commit
2c566c5320
2
image.c
2
image.c
@ -68,6 +68,7 @@ void img_init(img_t *img, win_t *win)
|
|||||||
img->alpha = ALPHA_LAYER;
|
img->alpha = ALPHA_LAYER;
|
||||||
img->multi.cap = img->multi.cnt = 0;
|
img->multi.cap = img->multi.cnt = 0;
|
||||||
img->multi.animate = options->animate;
|
img->multi.animate = options->animate;
|
||||||
|
img->multi.framedelay = options->framerate > 0 ? 1000 / options->framerate : 0;
|
||||||
img->multi.length = 0;
|
img->multi.length = 0;
|
||||||
|
|
||||||
img->cmod = imlib_create_color_modifier();
|
img->cmod = imlib_create_color_modifier();
|
||||||
@ -263,6 +264,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
|
|||||||
img->multi.cap * sizeof(img_frame_t));
|
img->multi.cap * sizeof(img_frame_t));
|
||||||
}
|
}
|
||||||
img->multi.frames[img->multi.cnt].im = im;
|
img->multi.frames[img->multi.cnt].im = im;
|
||||||
|
delay = img->multi.framedelay > 0 ? img->multi.framedelay : delay;
|
||||||
img->multi.frames[img->multi.cnt].delay = delay > 0 ? delay : DEF_GIF_DELAY;
|
img->multi.frames[img->multi.cnt].delay = delay > 0 ? delay : DEF_GIF_DELAY;
|
||||||
img->multi.length += img->multi.frames[img->multi.cnt].delay;
|
img->multi.length += img->multi.frames[img->multi.cnt].delay;
|
||||||
img->multi.cnt++;
|
img->multi.cnt++;
|
||||||
|
1
image.h
1
image.h
@ -35,6 +35,7 @@ typedef struct {
|
|||||||
int cnt;
|
int cnt;
|
||||||
int sel;
|
int sel;
|
||||||
bool animate;
|
bool animate;
|
||||||
|
int framedelay;
|
||||||
int length;
|
int length;
|
||||||
} multi_img_t;
|
} multi_img_t;
|
||||||
|
|
||||||
|
12
options.c
12
options.c
@ -32,7 +32,7 @@ const options_t *options = (const options_t*) &_options;
|
|||||||
|
|
||||||
void print_usage(void)
|
void print_usage(void)
|
||||||
{
|
{
|
||||||
printf("usage: sxiv [-abcfhioqrtvZ] [-e WID] [-G GAMMA] [-g GEOMETRY] "
|
printf("usage: sxiv [-abcfhioqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] [-g GEOMETRY] "
|
||||||
"[-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n");
|
"[-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +60,7 @@ void parse_options(int argc, char **argv)
|
|||||||
_options.animate = false;
|
_options.animate = false;
|
||||||
_options.gamma = 0;
|
_options.gamma = 0;
|
||||||
_options.slideshow = 0;
|
_options.slideshow = 0;
|
||||||
|
_options.framerate = 0;
|
||||||
|
|
||||||
_options.fullscreen = false;
|
_options.fullscreen = false;
|
||||||
_options.embed = 0;
|
_options.embed = 0;
|
||||||
@ -71,7 +72,7 @@ void parse_options(int argc, char **argv)
|
|||||||
_options.thumb_mode = false;
|
_options.thumb_mode = false;
|
||||||
_options.clean_cache = false;
|
_options.clean_cache = false;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "abce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) {
|
while ((opt = getopt(argc, argv, "aA:bce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case '?':
|
case '?':
|
||||||
print_usage();
|
print_usage();
|
||||||
@ -79,6 +80,13 @@ void parse_options(int argc, char **argv)
|
|||||||
case 'a':
|
case 'a':
|
||||||
_options.animate = true;
|
_options.animate = true;
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
_options.animate = true;
|
||||||
|
n = strtol(optarg, &end, 0);
|
||||||
|
if (*end != '\0' || n <= 0)
|
||||||
|
error(EXIT_FAILURE, 0, "Invalid argument for option -A: %s", optarg);
|
||||||
|
_options.framerate = n;
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
_options.hide_bar = true;
|
_options.hide_bar = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user