Original Post
I'm trying to load a bitmap with a small win32 console application. I do the following:
// load in the bitmap image
HBITMAP bit = (HBITMAP) LoadImage(NULL, "head 1_eyeL_hi.bmp", IMAGE_BITMAP, 0, 0,
LR_DEFAULTSIZE | LR_LOADFROMFILE);
if (!bit)
// failed to load, return failure to caller
printf("bitmap not loaded");
// get bitmap dimensions
BITMAP bitmap;
GetObject( bit, sizeof(BITMAP), &bitmap );
printf("width = %d\n\n", bitmap.bmType);
//BYTE *byBitData = (BYTE *) calloc(bitmap.bmBitsPixel * bitmap.bmHeight * bitmap.bmWidth, sizeof(BYTE));
BYTE *byBitData = (BYTE *) calloc(64*64, sizeof(BYTE));
byBitData = (BYTE *) bitmap.bmBits;
// get the pixel bits
printf("bits = %d\n\n", byBitData[0]);
The program crashes when trying to print the first bit data. The debugger says that byBitData and bitmap.bmBits are bad pointer. Sure enough, when I print them to the screen they are null (0.000). Dont know what I'm doing wrong here, hoe someone can help.