Skip to content

Commit 74b7946

Browse files
committed
Fixed anti-aliasing and GIF info printing
1 parent 9d09818 commit 74b7946

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Usage: ./xrootgif d:S:s:apt:Th [image]
1010
X-Screen to use, if none, use default screen
1111
-s | --speed [float]
1212
Playback speed as float
13-
-a | --anti-alias-off
14-
Don't use anti aliasing (Only use with native resolution GIFs)
13+
-a | --anti-alias
14+
Use anti-aliasing
1515
-p | --performance
1616
Performance mode - scale framerate to 5 (default)
1717
-t | --target-fps [float]

xrootgif.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
" X-Screen to use, if none, use default screen\n"\
4949
" -s | --speed [float]\n" \
5050
" Playback speed as float\n"\
51-
" -a | --anti-alias-off\n" \
52-
" Don't use anti aliasing (Only use with native resolution GIFs)\n"\
51+
" -a | --anti-alias\n" \
52+
" Use anti-aliasing\n"\
5353
" -p | --performance\n" \
5454
" Performance mode - scale framerate to 5 (default)\n"\
5555
" -t | --target-fps [float]\n" \
@@ -352,7 +352,17 @@ int load_pixmaps_from_image()
352352
root_attr.height, root_attr.depth);
353353
XSync(display, false);
354354

355-
/* Render image on canvas */
355+
/* set current frame's fields */
356+
delay = (gcb.DelayTime) ? gcb.DelayTime : 1; // Min delay time
357+
Background_anim.frames[i].p = pmap;
358+
Background_anim.frames[((i==0) ? gif->ImageCount : i)-1].dur
359+
= opts.speed*(10000*delay);
360+
avg_delay += delay;
361+
362+
printf("Image %d -- Top: %d; Left, %d; Width: %d; Height: %d; Delay: %d; Interlace: %s\n", i,
363+
desc.Top, desc.Left, desc.Width, desc.Height, gcb.DelayTime,
364+
desc.Interlace ? "True" : "False");
365+
356366
render_image(gif, &gcb, &gif->SavedImages[i], canvas, &color_total);
357367

358368

@@ -361,6 +371,7 @@ int load_pixmaps_from_image()
361371
gif->SHeight,
362372
canvas);
363373
imlib_context_set_image(img);
374+
imlib_context_set_anti_alias(opts.anti_alias);
364375
img_scaled = imlib_create_cropped_scaled_image(
365376
0, 0, gif->SWidth, gif->SHeight, root_attr.width,
366377
root_attr.height);
@@ -381,16 +392,6 @@ int load_pixmaps_from_image()
381392
/* Dispose image */
382393
dispose_image(gif, &gcb, &gif->SavedImages[i], canvas, old_canvas);
383394
memcpy(old_canvas, canvas, canvas_size);
384-
385-
delay = (gcb.DelayTime) ? gcb.DelayTime : 1; // Min delay time
386-
Background_anim.frames[i].p = pmap;
387-
Background_anim.frames[((i==0) ? gif->ImageCount : i)-1].dur
388-
= opts.speed*(10000*delay);
389-
avg_delay += delay;
390-
391-
printf("Image %d -- Top: %d; Left, %d; Width: %d; Height: %d; Delay: %d; Interlace: %s\n", i,
392-
desc.Top, desc.Left, desc.Width, desc.Height, gcb.DelayTime,
393-
desc.Interlace ? "True" : "False");
394395
}
395396

396397
avg_delay = 100.0/(avg_delay/gif->ImageCount);
@@ -462,7 +463,7 @@ int parse_args(int argc, char **argv)
462463
{"display", required_argument, NULL, 'd'},
463464
{"screen", required_argument, NULL, 'S'},
464465
{"speed", required_argument, NULL, 's'},
465-
{"anti-alias-off", no_argument, NULL, 'a'},
466+
{"anti-alias", no_argument, NULL, 'a'},
466467
{"performance", no_argument, NULL, 'p'},
467468
{"target-fps", required_argument, NULL, 't'},
468469
{"test-pattern", no_argument, NULL, 'T'},
@@ -472,7 +473,7 @@ int parse_args(int argc, char **argv)
472473

473474
/* Defaults */
474475
opts.speed = 1.0;
475-
opts.anti_alias = 1;
476+
opts.anti_alias = 0;
476477
opts.target_fps = 5.0;
477478
opts.performance = false;
478479
opts.do_test = false;
@@ -491,7 +492,7 @@ int parse_args(int argc, char **argv)
491492
opts.speed = 1.0/tmp;
492493
break;
493494
case 'a':
494-
opts.anti_alias = 0;
495+
opts.anti_alias = 1;
495496
break;
496497
case 'p':
497498
opts.performance = true;

0 commit comments

Comments
 (0)