0
我的MFC应用程序出现问题。当我试图从存档中反序列化CBitmap并创建新的CBitmap时,它不会正确加载CBitmap的位。从存档中反序列化位图
下面的代码:
BITMAP bm;
ar >> bm.bmType;
ar >> bm.bmWidth;
ar >> bm.bmHeight;
ar >> bm.bmWidthBytes;
ar >> bm.bmPlanes;
ar >> bm.bmBitsPixel;
int nSize = bm.bmWidth * bm.bmHeight;
bm.bmBits = new BYTE[nSize];
ar.Read(bm.bmBits, nSize);
CBitmap* tmp = new CBitmap;
tmp->CreateBitmapIndirect(&bm);
BITMAP bmi;
tmp->GetBitmap(&bmi);
HBITMAP hNew = (HBITMAP)CopyImage((HBITMAP)(*tmp), IMAGE_BITMAP,
bmi.bmWidth, bmi.bmHeight, LR_CREATEDIBSECTION);
m_bmp.Attach(hNew);
delete tmp;
后,我做的TMP-> GetBitmap(& BMI);我得到NULL到bmi.bmBits字段。
这是什么问题?我怎样才能使它工作?
P.S.我不能在* .bmp文件中使用序列化。
在此先感谢迈克。
太感谢你了,尼古拉!真的行!上帝祝福你!!! – Mike 2009-12-13 21:36:07