I have the following proc adjusted for 16x16 images that make some manipulations with original image and should copy result into hDC.
Everything is working perfect in all OSes except old good Windows95. The resulted image is surrounded with a black background. Were am I goes wrong?

someproc proc uses ebx esi edi hDC, pRect, himl, image

local dcMem :DWORD
local pBmpMask :DWORD
local dcMask :DWORD
local bmpOld :DWORD
local pvBits :DWORD
local bitmap :DWORD
local pOld1 :DWORD
local pOld2 :DWORD
local bmi :BITMAPINFO

invoke CreateCompatibleDC, 0
mov dcMask, eax
invoke CreateBitmap, 16, 16, 1, 1, 0
mov pBmpMask, eax
invoke SelectObject, dcMask, eax
mov pOld1, eax

invoke CreateCompatibleDC, hDC
mov dcMem, eax
mov ebx, eax
lea edi, bmi
mov ecx, sizeof(BITMAPINFO)/4
rep stosd
mov eax, 16
mov bmi.bmiHeader.biSize, sizeof(BITMAPINFOHEADER)
mov bmi.bmiHeader.biWidth, eax
mov bmi.bmiHeader.biHeight, eax
mov bmi.bmiHeader.biPlanes, 1
shl eax, 1
mov bmi.bmiHeader.biBitCount, ax
mov bmi.bmiHeader.biCompression, BI_RGB
shl eax, 3
mov bmi.bmiHeader.biSizeImage, eax
mov edi, eax
invoke CreateDIBSection, ebx,addr bmi, DIB_RGB_COLORS, addr pvBits, ecx, ecx
test eax, eax
jz @@end
mov bitmap, eax
invoke SelectObject, ebx, eax
mov pOld2, eax
xor eax, eax ; for coordinates and background
lea edx, [eax-1] ; for the foreground
invoke ImageList_DrawEx, himl, image, ebx, eax, eax, eax, eax, eax, edx, eax ;ILD_NORMAL
invoke SetBkColor, ebx, 0
invoke BitBlt,dcMask,0,0,16,16,ebx,0,0,SRCCOPY ; create the black mask of image

mov esi, pvBits
mov eax, [esi]
test eax, eax
jz @@skip_transparent_pixel

; here goes some per pixel
; manipulations in a loop
; skiping transparency pixels
; trying to blit back image preserving transparency
mov ebx, dcMem
invoke SetBkColor, ebx, ecx ; ecx=0 here
mov edi, pRect
invoke BitBlt, hDC, [edi].RECT.left, [edi].RECT.top, 16, 16, dcMask, 0, 0, SRCAND
; in win95 here is just black square, but should be just black mask, I think the problem
; is here, maybe I should use another ROP than SRCAND?
invoke BitBlt, hDC, [edi].RECT.left, [edi].RECT.top, 16, 16, ebx, 0, 0, SRCPAINT
; clean up code here
someproc endp
Posted on 2004-01-12 11:52:30 by masquer