How do I create a from an array?
Posted on 1997-10-22
PIX_PTR is an array of colors(chars) which I should be able to display as a bitmap. The palette I will use is a 16 color palette of user defined colors. I am not going to deal with the palette issue here, but it is important to know that the only colors used are 0-15. I have used the following code to attempt to display the contents of PIX_PTR as a bitmap.
GetClientRect( hWnd, (LPRECT) &rect );
hbmp = CreateBitmap(320, 200, 1, 4, PIX_PTR);
hdc = GetDC(hWnd);
hdcMemory = CreateCompatibleDC(hdc);
hbmpOld = SelectObject(hdcMemory, hbmp);
BitBlt(hdc, 0, 0, 320, 200, hdcMemory, 0, 0, SRCCOPY);
When the program is run, this code displays nothing. I can get it to display something by using a 1 in place of 4 in parameter 4 of CreateBitmap. Of course the display is monochrome and erroneous, but it does display something. I am not loading any palette information at this time, I plan to work on that after I get PIX_PTR to display something using any colors. I assume there is a predefined palette, default or otherwise. I have also tried to use CreateBitmapIndirect with no success by using the following settings.
bm.bmType = 0;
bm.bmWidth = 320;
bm.bmHeight = 200;
bm.bmWidthBytes = 256;
bm.bmPlanes = 1;
bm.bmBitsPixel = 4;
bm.bmBits = PIX_PTR;
hbmp = CreateBitmapIndirect(&bm);
The information I can find on "bm"(BITMAP) is wrong or just not available. Do you know what values I should use for bmWidthBytes? What is bmWidthBytes? Since I am using only 16 colors shouldn't bmBits be set to 4?
I have spent a lot of time attempting to make this work, any suggestions you may have would be greatly appreciated.