Fixed garbage in toolbar buttons
Dimitrie O. Paun
dpaun at rogers.com
Mon Oct 14 10:19:42 CDT 2002
On October 14, 2002 11:16 am, Carlos wrote:
> Then it has initted the bitmap, and with a SRCPAINT the result is
> correct, but if it hasn't passed by this point, when it uses SRCPAINT
> it mixes with the garbage in the buffer, because it wasn't cleared,
> then in this case SRCCOPY looks like correct. Maybe that it should be
> CLEAR+SRCAND+SRCPAINT?
You are correct, my mistake, I'm sorry. In fact, I just realized it
a little while after sending the message, and I just finished an
alternative patch (attached to this message). You are right, we should
just SRCCOPY the image if we don't have a solid background. My
patch just does a small code cleanup (and updates comments) to make
clear what we're doing. Can you please let me know if it works
as advertised?
--
Dimi.
Index: dlls/comctl32/imagelist.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/imagelist.c,v
retrieving revision 1.61
diff -u -r1.61 imagelist.c
--- dlls/comctl32/imagelist.c 24 Sep 2002 18:26:42 -0000 1.61
+++ dlls/comctl32/imagelist.c 14 Oct 2002 15:14:02 -0000
@@ -1083,7 +1083,7 @@
cx = (pimldp->cx == 0) ? himl->cx : pimldp->cx;
cy = (pimldp->cy == 0) ? himl->cy : pimldp->cy;
clrBk = (pimldp->rgbBk == CLR_DEFAULT) ? himl->clrBk : pimldp->rgbBk;
- bIsTransparent = himl->hbmMask && ((fStyle & ILD_TRANSPARENT) || clrBk == CLR_NONE);
+ bIsTransparent = (fStyle & ILD_TRANSPARENT) || clrBk == CLR_NONE;
bBlend = fStyle & (ILD_BLEND25 | ILD_BLEND50);
TRACE("hbmMask(0x%08x) iImage(%d) x(%d) y(%d) cx(%d) cy(%d)\n",
@@ -1115,15 +1115,8 @@
oldImageFg = SetTextColor( hImageDC, RGB( 0, 0, 0 ) );
oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) );
- /* If we have an opaque image, draw the background */
- if (!bIsTransparent && himl->hbmMask) {
- HBRUSH hOldBrush = SelectObject (hImageDC, CreateSolidBrush (clrBk));
- PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
- DeleteObject (SelectObject (hImageDC, hOldBrush));
- }
-
/*
- * Draw Image over the current background
+ * Draw the initial image
*/
if(fStyle & ILD_MASK) {
if (himl->hbmMask) {
@@ -1133,12 +1126,15 @@
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY);
SelectObject(hImageDC, hOldBrush);
}
- } else if (himl->hbmMask) {
+ } else if (himl->hbmMask && !bIsTransparent) {
+ /* blend the image with the needed solid background */
+ HBRUSH hOldBrush = SelectObject (hImageDC, CreateSolidBrush (clrBk));
+ PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCAND );
BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCPAINT );
+ DeleteObject (SelectObject (hImageDC, hOldBrush));
} else {
- /* the image is opaque, just copy it */
- TRACE(" - Image is opaque\n");
+ /* start off with the image, if we have a mask, we'll use it later */
BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCCOPY);
}
@@ -1194,7 +1190,7 @@
/* now copy the image to the screen */
dwRop = SRCCOPY;
- if (bIsTransparent && !(fStyle & ILD_MASK)) {
+ if (himl->hbmMask && bIsTransparent && !(fStyle & ILD_MASK)) {
COLORREF oldDstFg = SetTextColor(pimldp->hdcDst, RGB( 0, 0, 0 ) );
COLORREF oldDstBk = SetBkColor(pimldp->hdcDst, RGB( 0xff, 0xff, 0xff ));
BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hMaskListDC, lx, ly, SRCAND);
More information about the wine-devel
mailing list