Hello!
I'm using the following code to create a BITMAP. When the biCompression member for BITMAPINFOHEADER is set to BI_RGB, all works fine. However, I would like the BITMAP to be compressed, so I change the member to BI_RLE8 - the procedure then fails when CreateDIBSection is invoked.
What other memebers do I have to change for the BITMAP to be created with compression?
local bmpinfo:BITMAPINFO
invoke GetDC,0
mov hdc,eax
.IF (eax==NULL)
invoke MessageBox, 0, addr szNoDC, NULL, 0
jmp ExitFunc
.ENDIF
invoke GetDeviceCaps, hdc, BITSPIXEL
mov dwBPP,eax
.IF (eax<=8)
invoke GetDeviceCaps, hdc, NUMCOLORS
mov dwNumColors,eax
.ELSE
mov dwNumColors,0
.ENDIF
invoke GetDeviceCaps, hdc, LOGPIXELSY
mov pixelHeight,eax
invoke CreateCompatibleDC,hdc
mov memdc,eax
.IF (eax==NULL)
invoke DeleteDC, hdc
invoke MessageBox, 0, addr szNoMemDC, NULL, 0
jmp ExitFunc
.ENDIF
invoke ReleaseDC,0,hdc
invoke DeleteDC,hdc
mov bmpinfo.bmiHeader.biSize,sizeof BITMAPINFOHEADER
mov eax,dwWidth
mov bmpinfo.bmiHeader.biWidth,eax
mov eax,dwHeight
mov bmpinfo.bmiHeader.biHeight,eax
mov bmpinfo.bmiHeader.biPlanes,1
mov ax,word ptr [dwBPP]
mov bmpinfo.bmiHeader.biBitCount,ax
mov bmpinfo.bmiHeader.biCompression,BI_RLE8 ;BI_RGB
mov bmpinfo.bmiHeader.biSizeImage,0
mov bmpinfo.bmiHeader.biXPelsPerMeter,0
mov bmpinfo.bmiHeader.biYPelsPerMeter,0
mov eax,dwNumColors
mov bmpinfo.bmiHeader.biClrUsed,eax
mov bmpinfo.bmiHeader.biClrImportant,eax
invoke CreateDIBSection,memdc,addr bmpinfo,DIB_RGB_COLORS,addr pBits, NULL, 0
mov hBitmap,eax
.IF (eax==NULL)
invoke DeleteDC, hdc
invoke DeleteDC, memdc
invoke MessageBox, 0, addr szNoBMP, NULL, 0
jmp ExitFunc
.ENDIF
invoke SelectObject, memdc, hBitmap
.IF (eax==NULL) || (eax==GDI_ERROR)
invoke DeleteDC, hdc
invoke DeleteDC, memdc
invoke MessageBox, 0, addr szNoObj, NULL, 0
jmp ExitFunc
.ENDIF
Assistance will be greatly appreciated!
Regards,
George
On most systems the call to GetDeviceCaps, hdc, BITSPIXEL will return 32, and BI_RLE8 is only for bitmaps with 8 bpp.
Also, a DIB is always 32bpp. The BI_RLE8 value is probably only relevant for file loading/saving.
Cheers,
Zooba :U
Thanks for the info!