[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GDI+ take 3
From: |
Eli Zaretskii |
Subject: |
Re: GDI+ take 3 |
Date: |
Wed, 15 Apr 2020 21:13:54 +0300 |
> From: Juanma Barranquero <address@hidden>
> Date: Wed, 15 Apr 2020 19:49:25 +0200
> Cc: address@hidden, Emacs developers <address@hidden>
>
> > Great, thanks. 10 is indeed 0.1 sec, so I think I know how to fix the
> > code. But I will need you to test it :-(
>
> Go ahead. There's nothing if not free time in this covid-19 inflicted times
> ;-)
Thanks. The patch is below. It's a bit overboard, but hey! COVID-19
justifies that, no?
diff --git a/src/w32image.c b/src/w32image.c
index 6a3e37c..20fc94f 100644
--- a/src/w32image.c
+++ b/src/w32image.c
@@ -200,6 +200,43 @@ w32_can_use_native_image_api (Lisp_Object type)
return gdiplus_startup ();
}
+enum PropertyItem_type {
+ PI_BYTE = 1,
+ PI_ASCIIZ = 2,
+ PI_USHORT = 3,
+ PI_ULONG = 4,
+ PI_ULONG_PAIR = 5,
+ PI_BYTE_ANY = 6,
+ PI_LONG = 7,
+ PI_LONG_PAIR = 10
+};
+
+static unsigned long
+decode_delay (PropertyItem *propertyItem, int frame)
+{
+ enum PropertyItem_type type = propertyItem[frame].type;
+ unsigned delay;
+
+ switch (type)
+ {
+ case PI_BYTE:
+ case PI_BYTE_ANY:
+ delay = *((unsigned char *)propertyItem[frame].value);
+ break;
+ case PI_USHORT:
+ delay = *((unsigned short *)propertyItem[frame].value);
+ break;
+ case PI_ULONG:
+ case PI_LONG: /* delay shuold always be positive */
+ delay = *((unsigned long *)propertyItem[frame].value);
+ break;
+ default:
+ emacs_abort ();
+ }
+
+ return delay;
+}
+
static double
w32_frame_delay (GpBitmap *pBitmap, int frame)
{
@@ -217,13 +254,14 @@ w32_frame_delay (GpBitmap *pBitmap, int frame)
{
/* Get the property item. */
GdipGetPropertyItem (pBitmap, PropertyTagFrameDelay, size, propertyItem);
- delay = propertyItem[frame].length / 100.0;
- if (delay == 0)
+ delay = decode_delay (propertyItem, frame);
+ if (delay <= 0)
{
/* In GIF files, unfortunately, delay is only specified for the first
frame. */
- delay = propertyItem[0].length / 100.0;
+ delay = decode_delay (propertyItem, 0);
}
+ delay /= 100.0;
free (propertyItem);
}
return delay;
- Re: GDI+ take 3, (continued)
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/15
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/15
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/15
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/15
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/15
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/15
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/15
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/15
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/15
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/15
- Re: GDI+ take 3,
Eli Zaretskii <=
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/15
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/15
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/15
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/16
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/16
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/17
- Re: GDI+ take 3, Juan José García-Ripoll, 2020/04/17
- Re: GDI+ take 3, Juanma Barranquero, 2020/04/17
- Re: GDI+ take 3, Eli Zaretskii, 2020/04/17
- Re: GDI+ take 3, Juan José García-Ripoll, 2020/04/18