What is wrong with this way of displaying a bitmap on a window?
-
I'm trying to display a bitmap on my window. Here's my code:
BITMAPINFO biBitmap = {0};
BITMAPINFOHEADER bihBitmap = {0};bihBitmap.biSize = sizeof(BITMAPINFOHEADER);
bihBitmap.biWidth = 16;
bihBitmap.biHeight = 16;
bihBitmap.biPlanes = 1;
bihBitmap.biBitCount = 24;
bihBitmap.biCompression = BI_RGB;
bihBitmap.biSizeImage = 0;
bihBitmap.biClrUsed = 0;
bihBitmap.biClrImportant = 0;biBitmap.bmiHeader = bihBitmap;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(ghWnd, &ps);
HDC hdcMem = CreateCompatibleDC(NULL);HBITMAP hbm = CreateDIBitmap(hdcMem, &bihBitmap, CBM_INIT, finalrgb, &biBitmap, NULL);
HBITMAP hbmT = (HBITMAP)SelectObject(hdcMem, (HBITMAP)hbm);BitBlt(hdc,60,60,16,16,hdcMem,0,0,SRCCOPY);
SelectBitmap(hdcMem,hbmT);
DeleteDC(hdcMem);EndPaint(ghWnd,&ps);
finalrgb
is a pointer to an array of unsigned chars containing RGB values for a 16 by 16 pixels picture. What am i doing wrong? Thankyou!