I posted this question in the regular C++ forum and havn't gotten any answers.
hoping I will have better luck here, here was the question:
http://www.daniweb.com/forums/thread160790.html
I need to load a bitmap from file, and get an array of bits that I cain use.
I have used CreateDIBSection() to create a backbuffer for the screen.
my array is
UINT *pBits;
I need to load the bitmap so that I can go like this:
pBits[bit] = pLoadedBitmap[bit];
I am trying to get it to work like this right now:
HBITMAP hTexture;
BYTE *pBitData;
BITMAPINFO bmInfo;
BITMAP gBitmap;
hTexture = (HBITMAP)LoadImage(0, "texture.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);
GetObject(hTexture, sizeof(BITMAP), (LPVOID)&gBitmap);
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = gBitmap.bmWidth;
bmInfo.bmiHeader.biHeight = gBitmap.bmHeight;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = gBitmap.bmPlanes * gBitmap.bmBitsPixel;
bmInfo.bmiHeader.biCompression = BI_RGB;
bmInfo.bmiHeader.biSizeImage = gBitmap.bmWidth * gBitmap.bmHeight;
bmInfo.bmiHeader.biXPelsPerMeter = 0;
bmInfo.bmiHeader.biYPelsPerMeter = 0;
bmInfo.bmiHeader.biClrUsed = 0;
bmInfo.bmiHeader.biClrImportant = 0;
pBitData = new BYTE[bmInfo.bmiHeader.biSizeImage];
GetDIBits(0, hTexture, 0, 0, pBitData, &bmInfo, DIB_RGB_COLORS);
//when I do somdething like this:
for(int n = 0; n < bmInfo.bmiHeader.biSizeImage; n++
pBits[n] = pBitData[n];
//all I get is a mess of blue pixels that seems to be random.
can anyone help?