2 u011373710 u011373710 于 2013.12.04 09:58 提问

求大神为 VC++播放Gif线程代码 详细注释 真心是想学习啊!!!

static UINT GifThread(LPVOID GifDC)
{
CDC* pDC = (CDC*)GifDC;
HINSTANCE hAndle = ::AfxGetResourceHandle();
HRSRC hRsrc = ::FindResource(hAndle,MAKEINTRESOURCE(IDR_GIF1),"GIF");
DWORD word = ::SizeofResource(hAndle,hRsrc);
BYTE* lpBy = (BYTE*)LoadResource(hAndle,hRsrc);
BYTE* pByte[200];
DWORD nu[200];
int num = 0;
DWORD firstLocation = 0;
for(DWORD i=0;i<word;i++)
{
if(lpBy[i]==0x2c)
{
if(num==0)
{
firstLocation = i;
}
pGif nImage = (pGif)&lpBy[i+1];
DWORD number = 1+sizeof(Gif);
while(lpBy[i+number]!=0)
{
number = number+(DWORD)lpBy[i+number]+1;
}
number++;
pByte[num] = new BYTE[number];
for(DWORD n=0;n<number;n++)
{
(BYTE)(pByte[num]+n) = lpBy[i+n];
}
nu[num] = number;
i = i+number-1;
num++;
}
}
while(1)
{
for(int m=0;m<num;m++)
{
DWORD dWord;
VirtualProtect(lpBy,word,PAGE_READWRITE,&dWord);
for(DWORD n=0;n<nu[m];n++)
{
lpBy[firstLocation+n] = (BYTE)(pByte[m]+n);
}
VirtualProtect(lpBy,word,dWord,NULL);

        CMemFile mfile(lpBy,word);
        CArchive aRc(&mfile,CArchive::load|CArchive::bNoFlushOnDelete);
        CArchiveStream aRcstream(&aRc);
        CComQIPtr<IPicture> m_picture;
        OleLoadPicture((LPSTREAM)&aRcstream,0,false,IID_IPicture,(void**)&m_picture);
        long x,y;
        m_picture->get_Width(&x);
        m_picture->get_Height(&y);
        CSize size(x,y);
        pDC->HIMETRICtoDP(&size);
        CRect rect;
        m_picture->Render(*pDC,0,0,size.cx,size.cy,0,y,x,-y,&rect);
        Sleep(30);
    }
}
return 1;

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!