For now I'm just trying to copy one bitmap created with LoadImage() to another bitmap created with CreateCompatibleBitmap(). Problem is, the second bitmap ends up with all black pixels. Below is my code so far. I'm not sure about bi.biSizeImage, but I saw it in a few examples I found on MSDN.
After that I select bmp2 into hdc and BitBlt it to a window but it's just a pure black bitmap. I was able to copy using GetBitmapBits() and SetBitmapBits() but I don't want to use those if they're deprecated.Code:hdc = CreateCompatibleDC(NULL); bmp1 = (HBITMAP)LoadImage(NULL, L"bmp.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); bmp2 = CreateCompatibleBitmap(hdc, 256, 16); BITMAP bmp; GetObject(bmp1, sizeof(BITMAP), &bmp); BITMAPINFOHEADER bi; bi.biSize = sizeof(BITMAPINFOHEADER); bi.biWidth = bmp.bmWidth; bi.biHeight = bmp.bmHeight; bi.biPlanes = 1; bi.biBitCount = 24; bi.biCompression = BI_RGB; bi.biSizeImage = ((((bi.biWidth * bi.biBitCount) + 31) & ~31) >> 3) * bi.biHeight; char* bits = new char[bi.biSizeImage]; int ret1 = GetDIBits(hdc, bmp1, 0, bi.biHeight, bits, (BITMAPINFO*)&bi, DIB_RGB_COLORS); int ret2 = SetDIBits(hdc, bmp2, 0, bi.biHeight, bits, (BITMAPINFO*)&bi, DIB_RGB_COLORS);




Reply With Quote