CImage得到位图的大小

CImage image;
image.Load(_T("1.jpg"));
//HBITMAP hBitmap=image.Detach();

HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, 0);
IStream *pstm=NULL;
CreateStreamOnHGlobal(m_hMem, TRUE, &pstm);

image.Save(pstm,ImageFormatBMP);


LARGE_INTEGER liBeggining = { 0 };
pstm->Seek(liBeggining, STREAM_SEEK_SET, NULL);
DWORD size = GlobalSize(m_hMem);
LPBYTE lpData = (LPBYTE)GlobalLock(m_hMem);
CFile BMPfile(L"11.bmp",CFile::modeReadWrite | CFile::modeCreate);
BMPfile.Write (lpData,size);
BMPfile.Close();
pstm->Release();
GlobalUnlock(m_hMem);

posted @ 2022-12-23 17:51  阿风小子  阅读(34)  评论(0编辑  收藏  举报