- /* now instantiate */
- MAYBE_DEVMETH (XDEVICE (ii->device),
- init_image_instance_from_eimage,
- (ii, width, height, unwind.eimage, dest_mask,
- instantiator, domain));
+
+ /* We read the gif successfully. If we have more than one slice then
+ animate the gif. */
+ if (unwind.giffile->ImageCount > 1)
+ {
+ /* See if there is a timeout value. In theory there could be one
+ for every image - but that makes the implementation way to
+ complicated for now so we just take the first. */
+ unsigned short timeout = 0;
+ Lisp_Object tid;
+
+ if (unwind.giffile->SavedImages[0].Function == GRAPHICS_EXT_FUNC_CODE
+ &&
+ unwind.giffile->SavedImages[0].ExtensionBlockCount)
+ {
+ timeout = (unsigned short)
+ ((unwind.giffile->SavedImages[0].ExtensionBlocks[0].Bytes[2] << 8) +
+ unwind.giffile-> SavedImages[0].ExtensionBlocks[0].Bytes[1]) * 10;
+ }
+
+ /* Too short a timeout will crucify us performance-wise. */
+ tid = add_glyph_animated_timeout (timeout > 10 ? timeout : 10, image_instance);
+
+ if (!NILP (tid))
+ IMAGE_INSTANCE_PIXMAP_TIMEOUT (ii) = XINT (tid);
+ }