Gdiplus provides bitmap support for reading and displaying GIF files.
 
However, for some GIF pictures may appear between the frame interval of 0, for this reason, the default interval of 100ms in this case, do not know whether I did not find the right, there are suggestions welcome feedback. (Test in GIMP also will appear between the frame interval of 0, I think there should be a default value bar, 100ms effect can be accepted, for the moment borrowed)
 
#define UM_TIMER_GIFNEXTFRAME (WM_USER+0X01)//message for TIMER int iphotoframecurrent = 0; int iphotoframeindex; guid* pphotoframedimensionids = NULL; propertyitem* Pphotoframeitem = NULL; void Gifinit (bitmap* psrc) {iphotoframeindex = Psrc->getframedimensionscount (); pphotoframedimensionids = (GUID*) New Guid[iphotoframeindex]; Psrc->getframedimensionslist (Pphotoframedimensionids, Iphotoframeindex); WCHAR strguid[64] = {0}; StringFromGUID2 (Pphotoframedimensionids[0], strGUID, 64); int Iphotoframecount=psrc->getframecount (&pphotoframedimensionids[0]); if (iphotoframecount==1)//not dynamic GIF, only one frame {return;} UINT Totalbuffer = psrc->getpropertyitemsize (Propertytagframedelay); Pphotoframeitem = (propertyitem*) malloc (Totalbuffer); Psrc->getpropertyitem (Propertytagframedelay,totalbuffer,pphotoframeitem); iphotoframecurrent = 0; GUID guid = Framedimensiontime; Psrc->selectactiveframe (&guid,iphotoframecurrent); Get-current frame int delay = (UINT*) (Pphotoframeitem[0].value) [iphotoframecurrent]; if (0==delay)//No delay time, use default 100ms {delay = 100;} SetTimer (um_timer_gifnextframe, delay, NULL); + + iphotoframecurrent; g_bgifstoped = FALSE; } void OnTimer (Uint_ptr nidevent) {if (Um_timer_gifnextframe = = nidevent) {KillTimer (nidevent); if (iphotoframecount==1) {return;} GUID guid = Framedimensiontime; Psrc->selectactiveframe (&guid,iphotoframecurrent); int delay = ((uint*) pphotoframeitem[0].value) [iphotoframecurrent]*10; I also want to know why Mul?? if (0==delay) delay = 100; SetTimer (um_timer_gifnextframe, delay, NULL); Iphotoframecurrent = (++iphotoframecurrent)% Iphotoframecount; } free (Pphotoframeitem); Free after used! Delete [] Pphotoframedimensio
 
 
See the specific code.
 
The main idea is to read the GIF file, through Psrc->getframecount () to get the number of frames in GIF, through the Psrc->selectactiveframe () to set the current picture as the X frame in GIF, and finally through sleep () and Timer () to implement the time delay and current frame update.
 
 
In the preceding code:
 
bitmap* PSRC =:: New Bitmap (filename);
 
The same last need
 
::d elete psrc;