From c13c543cfef9aaad1fa58e2213b6ac02091ff52a Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Wed, 29 Jul 2020 22:09:10 -0700 Subject: [PATCH] Wrap up GIF export; support speed Different speed settings in slideshow dialog affect the speed of the exported GIF. --- docs/CHANGES.txt | 3 +-- src/gifenc.c | 8 ++++++++ src/tuxpaint.c | 11 +++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index d5a4a84b7..311b3611b 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -8,7 +8,7 @@ http://www.tuxpaint.org/ $Id$ -2020.July.27 (0.9.25) +2020.July.29 (0.9.25) * New Features ------------ * Export drawings: @@ -19,7 +19,6 @@ $Id$ * Depends on "libimagequant", from the "pngquant2" project: https://github.com/ImageOptim/libimagequant (GPL v3 or later, for Free/Libre Open Source Software) - * WORK IN PROGRESS -- Ignores speed * Single image (PNG) export from the Open dialog. (Closes https://sourceforge.net/p/tuxpaint/feature-requests/192/) * Both utilize XDG user dirs settings, if available, to determine diff --git a/src/gifenc.c b/src/gifenc.c index 640315266..c74998adf 100644 --- a/src/gifenc.c +++ b/src/gifenc.c @@ -246,6 +246,14 @@ get_bbox(ge_GIF *gif, uint16_t *w, uint16_t *h, uint16_t *x, uint16_t *y) } } +/* (From the docs) + * The `delay` parameter specifies how long the frame will be shown, in hundreths + * of a second. For example, `delay` == 100 means "show this frame for one second" + * and `delay` == 25 means "show this frame for a quarter of a second". Note that + * short delays may not be supported by some GIF viewers: it's recommended to keep + * a minimum of `delay` == 6. If `delay` == 0, no delay information will be stored + * for the frame. This can be used when creating still (single-frame) GIF images. + */ static void set_delay(ge_GIF *gif, uint16_t d) { diff --git a/src/tuxpaint.c b/src/tuxpaint.c index e39ce47fa..a2c2b7f2c 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - July 27, 2020 + June 14, 2002 - July 29, 2020 */ @@ -25389,6 +25389,7 @@ static int export_gif(int *selected, int num_selected, char *dirname, char **d_n liq_result *quantization_result; liq_error qtiz_status; const liq_palette *palette; + int gif_speed; /* Back up the current image's IDs, because they will get clobbered below! */ @@ -25415,6 +25416,12 @@ static int export_gif(int *selected, int num_selected, char *dirname, char **d_n overall_h = screen->h; overall_area = overall_w * overall_h; + if (speed == 0) + { + gif_speed = 1; + } + gif_speed = (10 - speed) * 50; + bitmap = malloc(num_selected * overall_area * 4); if (bitmap != NULL) { @@ -25517,7 +25524,7 @@ static int export_gif(int *selected, int num_selected, char *dirname, char **d_n for (i = 0; i < num_selected && !done; i++) { memcpy(gif->frame, raw_8bit_pixels + i * overall_area, overall_area); - ge_add_frame(gif, 100); // FIXME: Speed + ge_add_frame(gif, gif_speed); show_progress_bar(screen); done = export_gif_monitor_events();