summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Moyer <gnome-bugzilla@keithmoyer.com>2011-10-01 01:32:40 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2011-10-01 01:47:45 +0200
commitee81d3fc611a0e64dc55c4f2a2fda73932de2fe6 (patch)
tree0a90f885b268207f9954c01add58cb8cf4e0e989
parent6d7457158356dcc4ec310f6b5d0951b470216b6f (diff)
downloadgdk-pixbuf-ee81d3fc611a0e64dc55c4f2a2fda73932de2fe6.tar.gz
gdip: fix gif animation delays between frames
1. delay value of first frame was being used for all frames 2. when a frame specifies a delay of 0ms, use 100ms instead of 20ms (matches gdk-pixbuf/io-gif.c) 3. when a frame specifies a delay of < 20ms, use 20ms instead (also matches gdk-pixbuf/io-gif.c) https://bugzilla.gnome.org/show_bug.cgi?id=655755
-rw-r--r--gdk-pixbuf/io-gdip-utils.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/gdk-pixbuf/io-gdip-utils.c b/gdk-pixbuf/io-gdip-utils.c
index 8f62d75d8..01befd807 100644
--- a/gdk-pixbuf/io-gdip-utils.c
+++ b/gdk-pixbuf/io-gdip-utils.c
@@ -480,9 +480,9 @@ gdip_bitmap_get_property_as_string (GpBitmap *bitmap, guint propertyId, gchar **
}
static gboolean
-gdip_bitmap_get_frame_delay (GpBitmap *bitmap, guint *delay)
+gdip_bitmap_get_frame_delay (GpBitmap *bitmap, guint frame, guint *delay)
{
- guint item_size;
+ guint item_size, item_count;
gboolean success = FALSE;
if (bitmap == NULL || delay == NULL)
@@ -495,8 +495,9 @@ gdip_bitmap_get_frame_delay (GpBitmap *bitmap, guint *delay)
item = (PropertyItem *)g_try_malloc (item_size);
if (Ok == GdipGetPropertyItem ((GpImage *)bitmap, PropertyTagFrameDelay, item_size, item)) {
+ item_count = item_size / sizeof(long);
/* PropertyTagFrameDelay. Time delay, in hundredths of a second, between two frames in an animated GIF image. */
- *delay = *((long *)item->value);
+ *delay = ((long *)item->value)[(frame < item_count) ? frame : item_count - 1];
success = TRUE;
}
@@ -697,7 +698,7 @@ stop_load (GpBitmap *bitmap, GdipContext *context, GError **error)
frame = g_new (GdkPixbufFrame, 1);
frame->pixbuf = pixbuf;
- gdip_bitmap_get_frame_delay (bitmap, &frame_delay);
+ gdip_bitmap_get_frame_delay (bitmap, i, &frame_delay);
animation->n_frames++;
animation->frames = g_list_append (animation->frames, frame);
@@ -707,16 +708,20 @@ stop_load (GpBitmap *bitmap, GdipContext *context, GError **error)
/* GIF delay is in hundredths, we want thousandths */
frame->delay_time = frame_delay * 10;
- frame->elapsed = animation->total_time;
-
- /* Some GIFs apparently have delay time of 0,
- * that crashes everything so set it to "fast".
- * Also, timeouts less than 20 or so just lock up
- * the app or make the animation choppy, so fix them.
+
+ /* GIFs with delay time 0 are mostly broken, but they
+ * just want a default, "not that fast" delay.
*/
- if (frame->delay_time < 20)
+ if (frame->delay_time == 0)
+ frame->delay_time = 100;
+
+ /* No GIFs gets to play faster than 50 fps. They just
+ * lock up poor gtk.
+ */
+ else if (frame->delay_time < 20)
frame->delay_time = 20; /* 20 = "fast" */
+ frame->elapsed = animation->total_time;
animation->total_time += frame->delay_time;
if (i == 0)