what I'm trying to do is to load a bmp from memory, I can do it from a file, but when I'm trying to do it from memory (buffer) I get some exceptions...
here is the code:
BYTE *pBits;
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
ZeroMemory(&bmih,sizeof(bmih));
ZeroMemory(&bmfh,sizeof(bmfh));
memcpy(&bmfh,pDat,sizeof(bmfh));
memcpy(&bmih,pDat+sizeof(bmfh),sizeof(bmih));
long len=bmfh.bfSize-sizeof(bmfh)-sizeof(bmih);
pBits=new BYTE[len];
memcpy(pBits,pDat+bmfh.bfOffBits,len);
this is how I load it from a file (this is working):
BYTE *pBits;
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
FILE *pFile=fopen(FileName,"rb");
if (!pFile)
return NULL;
fread(&bmfh,sizeof(bmfh),1,pFile);
fread(&bmih,sizeof(bmih),1,pFile);
fseek(pFile,bmfh.bfOffBits,SEEK_SET);
long len=bmfh.bfSize-sizeof(bmfh)-sizeof(bmih);
pBits=new BYTE[len];
fread(pBits,len,1,pFile);
Thanks.