GDI error + gif

I use C ++ GDI + to open gif

however, I find the frame interval really strange. This is different from playing it with a pic viewer.

The code I wrote is as follows.

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 lPause <= 0. What does this mean?

And the code that I listed correctly to get the interval?

Many thanks!

+3
source share
2 answers

The frame duration field in the gif header has a length of only two bytes (interpreted as 100ths of a second - valid values ​​are from 0 to 32.768 seconds).

, long, , , 4 , . , , , .

+2

. , "FrameNumber" .

  • GetPropertyItemSize (PropertyTagFrameDelay) . Int32 "" . "long" 4 32- , 8 64- .

  • m_pMultiPageImg- > GetFrameDimensionsCount() , . ( ) .


int count = m_pMultiPageImg->GetFrameDimensionsCount();
GUID* dimensionIDs = new GUID[count];
m_pMultiPageImg->GetFrameDimensionsList(dimensionIDs, count);
int frameCount = m_pMultiPageImg->GetFrameCount(&m_pDimensionIDs[0]);

, .

+1

Source: https://habr.com/ru/post/1720434/


All Articles