win32 - GDI Plus: How can i get the frame delay from image animation?

i use GDIPLus for open image files.
but using the Image class, i can get the frames delay, but maybe i'm getting it on wrong way :(
1
2
3
PropertyItem ptFramedelay;
            img2.GetPropertyItem(PropertyTagFrameDelay, img2.GetPropertyItemSize(PropertyTagFrameDelay),&ptFramedelay);
            framedelay=ptFramedelay.length;

the compiler don't give me any error, only on execute mode, but by OS.
can anyone explain to me how i can get the frame delay?
finally i fix the compiler errors:
1
2
3
4
5
6
7
8
int nSize = img2.GetPropertyItemSize(PropertyTagFrameDelay);

            // Allocate a buffer to receive the property item.
            PropertyItem *m_pPropertyItem = (PropertyItem*) malloc(nSize);

            img2.GetPropertyItem(PropertyTagFrameDelay, nSize, m_pPropertyItem);

            framedelay = (long)m_pPropertyItem->value;

(frame delay is int; img2 it's an Image object)
i get a very big number :(
can anyone advice me?
i did a very big mistake: i need casting correctly from void* to int:
1
2
3
4
5
6
7
8
int nSize = img2.GetPropertyItemSize(PropertyTagFrameDelay);

            // Allocate a buffer to receive the property item.
            PropertyItem *m_pPropertyItem = (PropertyItem*) malloc(nSize);

            img2.GetPropertyItem(PropertyTagFrameDelay, nSize, m_pPropertyItem);

            framedelay =*((int *)m_pPropertyItem->value);

how casting from void* to any type:
*((typename*)voidpointervariablename)
but i get 100. the animation is to fast :(
Last edited on
Take a look at this again:

http://www.codeproject.com/Articles/1776/Adding-GIF-animation-using-GDI

long lPause = ((long*) m_pPropertyItem->value)[m_nFramePosition] * 10;

It is stored for each frame (hence the array) and it needs to be multiplied by 10.
Last edited on
imagine that the delay it's the same between the frames and it's 100(like before), i will get 1000.... don't make sence :(
(i did the test with index 0(zero))
Last edited on
i will get 1000.... don't make sence
Why not?
1000ms=1s
1 - it will be very slow between the frames;
2 - i don't belive that it's the real frame delay :(
see the image:
http://imgur.com/1wFGV3X
(the yellow smoking, with a gun animation)
Last edited on
This animation has certainly different delays between the frames. The shooting is faster than the smoking.
Topic archived. No new replies allowed.