GDI+播放GIF动图

来源:互联网 发布:java 数组为null 编辑:程序博客网 时间:2024/06/09 21:56
TCHAR szModule[MAX_PATH] = {0};GetModuleFileName(NULL,szModule,MAX_PATH);PathRemoveFileSpec(szModule);PathAppend(szModule,L"success.gif");Image img(szModule);UINT nCount = img.GetFrameDimensionsCount();GUID* pDimensionsIDs = (GUID*)new GUID[nCount];img.GetFrameDimensionsList(pDimensionsIDs,nCount);TCHAR strGUID[39]={0};StringFromGUID2(pDimensionsIDs[0],strGUID,39);UINT nFrameCount = img.GetFrameCount(&pDimensionsIDs[0]);delete[] pDimensionsIDs;int size = img.GetPropertyItemSize(PropertyTagFrameDelay);byte* p = new byte[size];PropertyItem*  pItem = (PropertyItem*)p;img.GetPropertyItem(PropertyTagFrameDelay,size, pItem);int fcount = 0;GUID guid = FrameDimensionTime;HDC hDC = ::GetDC(pDlg->GetSafeHwnd());</span>while(TRUE){Graphics gc(hDC);gc.DrawImage(&img,0,0,img.GetWidth(),img.GetHeight());img.SelectActiveFrame(&guid,fcount++);if (fcount == nFrameCount){fcount = 0;}long pause = ((long*)pItem->value)[fcount]*10;Sleep(pause);}::ReleaseDC(pDlg->GetSafeHwnd(),hDC);

0 0