Hello, everyone!
I've got a problem with my MFC app. When I'm trying to deserialize CBitmap from the archive and create new CBitmap, it doesn't properly load CBitmap's bits.
Here's the code:
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;
After I do tmp->GetBitmap(&bmi); I get NULL into bmi.bmBits field.
What's wrong with that? How can I make it work?
P.S. I mustn't use serialization into *.bmp file.
Thanks in advance, Mike.