views:

110

answers:

1

I am using C++ GDI+ to open a gif

however I find the frame interval is really strange. It is different from played it by window's pic viewer.

The code I written is as follow.

pMultiPageImg = new Bitmap(XXXXX);
int size = m_pMultiPageImg->GetPropertyItemSize(PropertyTagFrameDelay);
m_pTimeDelays = (PropertyItem*) malloc (size);
m_pMultiPageImg->GetPropertyItem(PropertyTagFrameDelay, size, m_pTimeDelays);
int frameSize =  m_pMultiPageImg->GetFrameDimensionsCount();();

// the interal of frame FrameNumber:
long lPause = ((long*)m_pTimeDelays->value)[FrameNumber] * 10;

however I found some frame the lPause <= 0. What does this mean?

And are code I listed right for get the interval?

Many thanks!

+1  A: 

The frame duration field in the gif header is only two bytes long (interpreted as 100ths of a second - allowing values from 0 to 32.768 seconds).

You seem to be interpreting it as long, which is probably 4 bytes on your platform so you will be reading another field along with the duration. It is hard to tell from the code you provide, but I think this is the problem.

Autopulated