I allocated a pixel buffer and I have a function that writes the bitmap bits
into it.
Q: how do I create an HBITMAP from this array of bytes?
thanks
Presuming your bitmap bits are in DIB format, you can use CreateDIBSection()
to create a DIBSection, then memcpy() your bits into the DIBSection. Or you
could use CreateDIBitmap().
Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.
so far i've got:
int w, h;
unsigned int nBytes;
BYTE* bits = GetRawBitmapBits(&w, &h, &nBytes); // allocs the bit buffer and
fills it
BITMAPINFO bmi;
memset (&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
bmi.bmiHeader.biWidth = w;
bmi.bmiHeader.biHeight = hehight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = nBytes;
//bmi.bmiColors = ????
BYTE* dibBits = NULL;
HBITMAP hBM = CreateDIBSection( hDC, &bmi,DIB_RGB_COLORS,(void**)&dibBits,
NULL, NULL );
SetDIBits(hDC, hBM, 0, h, buff, &bmi, DIB_RGB_COLORS); //copies my bits
into the DIB
free (bits);
return hBM
thanks!
"John Hornick [MSFT]" <JHor...@online.microsoft.com> wrote in message
news:VhTdjdjm...@cpmsftngxa06.phx.gbl...
You probably have the image bits in the wrong order. DIBs are stored
in BGR - loop through the image bits and swap the R and G bytes.