[C++] Create HBITMAP from Byte Array
HBITMAP CreateHBITMAPfromByteArray(HDC hdc, int nImageWidth, int nImageHeight, BYTE* pImageData)
{
BITMAPINFOHEADER bmih;
memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
bmih.biWidth = nImageWidth;
bmih.biHeight = nImageHeight;
bmih.biBitCount = 32;
bmih.biCompression = BI_RGB;
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biPlanes = 1;
BITMAPINFO* bmi = (BITMAPINFO*)&bmih;
return CreateDIBitmap(hdc, &bmih, CBM_INIT, pImageData, bmi, DIB_RGB_COLORS);
}
// When you no longer need the bitmap, call the DeleteObject function to delete it.