[10/10] x11drv / user: Fix 32bpp (BGRA) cursors

H. Verbeet hverbeet at gmail.com
Sat Aug 5 16:40:59 CDT 2006


Using CreateDIBitmap() will create a DDB with the bit depth of the
display. In most cases that's what we want, but in the case of a 32bpp
cursor that means we lose the alpha channel. This also adds code to
x11drv for loading the alpha value from the XOR data instead of the
AND data.
-------------- next part --------------
diff --git a/dlls/user/cursoricon.c b/dlls/user/cursoricon.c
index 6ade21a..352505e 100644
--- a/dlls/user/cursoricon.c
+++ b/dlls/user/cursoricon.c
@@ -1101,6 +1101,10 @@ static BOOL load_cursor_frame( LPBYTE bi
                   hXorBits = CreateBitmap(width, height, 1, 1, NULL);
                   SetDIBits(screen_dc, hXorBits, 0, height,
                      (char*)bmi + size, pInfo, DIB_RGB_COLORS);
+              } else if (bmi->bmiHeader.biBitCount == 32) {
+                  hXorBits = CreateDIBSection(screen_dc, pInfo, DIB_RGB_COLORS, NULL, NULL, 0);
+                  SetDIBits(screen_dc, hXorBits, 0, height,
+                     (char*)bmi + size, pInfo, DIB_RGB_COLORS);
               }
               else
                   hXorBits = CreateDIBitmap(screen_dc, &pInfo->bmiHeader,
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 5d3681a..5222896 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -402,6 +402,14 @@ static XcursorImage *create_cursor_image
             /* Xcursor pixel data is in ARGB format, with A in the high byte */
             switch (frame->bpp)
             {
+                case 32:
+                    /* BGRA, 8 bits each */
+                    *pixel_ptr = *xor_ptr++;
+                    *pixel_ptr |= *xor_ptr++ << 8;
+                    *pixel_ptr |= *xor_ptr++ << 16;
+                    *pixel_ptr |= *xor_ptr++ << 24;
+                    break;
+
                 case 24:
                     /* BGR, 8 bits each */
                     *pixel_ptr = *xor_ptr++;
@@ -426,18 +434,23 @@ static XcursorImage *create_cursor_image
                     FIXME("Currently no support for cursors with %d bits per pixel\n", frame->bpp);
                     return 0;
             }
-            /* Alpha channel */
-            if (~*and_ptr & (1 << (7 - (x & 7)))) *pixel_ptr |= 0xff << 24;
-            else if (*pixel_ptr)
+
+            if (frame->bpp != 32)
             {
-                int alpha = (*pixel_ptr & 0xff) * 0.30f
-                        + ((*pixel_ptr & 0xff00) >> 8) * 0.55f
-                        + ((*pixel_ptr & 0xff0000) >> 16) * 0.15f;
-                *pixel_ptr ^= ((x + y) % 2) ? 0xffffff : 0x000000;
-                *pixel_ptr |= alpha << 24;
+                /* Alpha channel */
+                if (~*and_ptr & (1 << (7 - (x & 7)))) *pixel_ptr |= 0xff << 24;
+                else if (*pixel_ptr)
+                {
+                    int alpha = (*pixel_ptr & 0xff) * 0.30f
+                            + ((*pixel_ptr & 0xff00) >> 8) * 0.55f
+                            + ((*pixel_ptr & 0xff0000) >> 16) * 0.15f;
+                    *pixel_ptr ^= ((x + y) % 2) ? 0xffffff : 0x000000;
+                    *pixel_ptr |= alpha << 24;
+                }
+
+                if ((x & 7) == 7) ++and_ptr;
             }
 
-            if ((x & 7) == 7) ++and_ptr;
             ++pixel_ptr;
         }
     }


More information about the wine-patches mailing list