Hi, everybody.
I've been trying to make a program that opens a bitmap file, reads it's
BITMAPINFOHEADER and RGBQUAD parts, and puts them in BITMAPINFO structure. I
managed to read the first header part, but I'm having problems with RGBQUAD.
When I comment out this part, the program works fine, but when I uncomment
it, the program just exits without any warning message. Here's the code:
-----------------------------------------------------------
{LPTSTR szFileName=TEXT("bitmapa.bmp");
HANDLE
hFile=CreateFile(szFileName,GENERIC_READ,0,NULL,OPEN_EXISTING, //open file
for reading
FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE)
MessageBox(hwnd,"Error","Can't open file",MB_OK);
else
MessageBox(hwnd,"FileOpen sucess","Success",MB_OK);
BITMAPINFO bmpInfo;
DWORD btCount;
SetFilePointer(hFile,sizeof(BITMAPFILEHEADER),NULL,FILE_BEGIN);
//set pointer to begining of the file
ReadFile(hFile,&(bmpInfo.bmiHeader),sizeof(BITMAPINFOHEADER),&btCount,NULL);
//read BITMAPINFOHEADER to bmpInfo;
ReadFile(hFile,&(bmpInfo.bmiColors),sizeof(RGBQUAD)*(2^bmpInfo.bmiHeader.biB
itCount),&btCount,NULL);//read RGBQUAD to bmpInfo
LPTSTR szOutput;
sprintf(szOutput,"width=%i,height=%i",(int)bmpInfo.bmiHeader.biWidth,(int)bm
pInfo.bmiHeader.biHeight);
MessageBox(hwnd,szOutput,"Result",MB_OK);
CloseHandle(hFile);}
---------------------------------------
I hope you guys can tell me what's wrong and is this the right way to do
this. Thanks
------------
Vlada
|