I have an array of pixels which I need to convert to HBITMAP in order to display it in a window. I tried to use CreateDIBitmap() but I don\'t have the BMP headers. I tried
The other answers here are very helpful, but i ended up being able to achieve it with just 1 line.
HBITMAP hBm = CreateBitmap(width,height,1,32,pixels); // 1 plane, 32 bits
Hope it may be useful to any future readers.
Also, there's CreateCompatibleBitmap and SetDIBits incase you need to use a device context.
At MSDN for CreateDIBitmap it states:
Calling CreateDIBitmap with fdwInit as CBM_INIT is equivalent to calling the CreateCompatibleBitmap function to create a DDB in the format of the device and then calling the SetDIBits function to translate the DIB bits to the DDB.