How would I create a bitmap object that can be selected into a memory DC out of the information from a bmp file in a buffer?
Posted on 2000-12-24 17:45:00 by plu
You would think this should be eazy, concidering windows are built out of so many bitmaps, but it's quite a bitch. You need to know all the possible formats of a bitmap image, all the structs, yetch. This code seemed to work for me. ; now get the bitmap resource invoke FindResource,hInstance, IDM_BITMAP_, RT_RCDATA ; get handle to resource invoke LoadResource, hInstance, eax invoke LockResource, eax ; get the bitmap to memory mov pBitmapFileHeader, eax xor edx, edx mov dx, cmp dx, 4D42H ; 'BM' in hex jne BadFile mov edx, pBitmapFileHeader add eax, (BITMAPFILEHEADER PTR ).bfOffBits mov pBitmapData, eax mov eax, pBitmapFileHeader add eax, SIZEOF BITMAPFILEHEADER mov pBitmapInfoHeader, eax mov edx, pBitmapInfoHeader mov eax, (BITMAPINFOHEADER PTR ).biWidth mov nWidth, eax mov eax, (BITMAPINFOHEADER PTR ).biHeight mov nHeight, eax invoke GetDC, hIDM_picture mov hDCtemp, eax invoke CreateCompatibleDC, hDCtemp mov hDC, eax invoke CreateDIBitmap, hDCtemp, pBitmapInfoHeader, CBM_INIT, pBitmapData, pBitmapInfoHeader, DIB_RGB_COLORS mov hBitmap, eax ; we can now assign this bitmap to a window invoke SendMessage, hIDM_picture, STM_SETIMAGE, IMAGE_BITMAP, hBitmap invoke ReleaseDC, hIDM_picture, hDCtemp invoke DeleteDC, hDCtemp
Posted on 2000-12-24 23:44:00 by Ernie
works great thanks :)
Posted on 2000-12-25 02:08:00 by dork