Fixes a regression introduced by c0bf67636ab3de46c67b8d02e44fb39b5853384a.
From: Paul Gofman pgofman@codeweavers.com
Fixes a regression introduced by c0bf67636ab3de46c67b8d02e44fb39b5853384a. --- dlls/uxtheme/msstyles.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/dlls/uxtheme/msstyles.c b/dlls/uxtheme/msstyles.c index aa78c372d15..1efd78f2295 100644 --- a/dlls/uxtheme/msstyles.c +++ b/dlls/uxtheme/msstyles.c @@ -1218,12 +1218,37 @@ static BOOL prepare_alpha (HBITMAP bmp, BOOL* hasAlpha, BOOL *hasDefaultTranspar }
if (dib.dsBm.bmBitsPixel != 32) + { + if (dib.dsBm.bmBitsPixel <= 8) + { + RGBQUAD p[256]; + HDC hdc = CreateCompatibleDC(NULL); + HBITMAP prev = SelectObject(hdc, bmp); + UINT count = GetDIBColorTable(hdc, 0, 256, p); + + SelectObject(hdc, prev); + DeleteDC(hdc); + + for (n = 0; n < count; ++n) + { + if (RGB(p[n].rgbRed, p[n].rgbGreen, p[n].rgbBlue) == DEFAULT_TRANSPARENT_COLOR) + { + *hasDefaultTransparentColour = TRUE; + return TRUE; + } + } + } return TRUE; + }
/* If all alpha values are 0xff, don't use alpha blending */ for (n = 0, p = dib.dsBm.bmBits; n < dib.dsBmih.biWidth * dib.dsBmih.biHeight; n++, p += 4) + { if ((*hasAlpha = (p[3] != 0xff))) break; + if (RGB(p[0], p[1], p[2]) == DEFAULT_TRANSPARENT_COLOR) + *hasDefaultTransparentColour = TRUE; + }
if (!*hasAlpha) return TRUE;
Fixes a regression described here: https://gitlab.winehq.org/wine/wine/-/merge_requests/6401#note_82961 (where the theme has 8 bit paletted bitmap with default transparent colour which was displayed as pink instead of being transparent after the blamed commit).
Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/msstyles.c:
} if (dib.dsBm.bmBitsPixel != 32)
- {
if (dib.dsBm.bmBitsPixel <= 8)
I think you need to check 16-bit bitmaps as well.
Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/msstyles.c:
if (!bmp || GetObjectW( bmp, sizeof(dib), &dib ) != sizeof(dib)) return FALSE; if (dib.dsBmih.biCompression != BI_RGB)
The regression probably applies to other bitmap compression formats as well. For example, BI_BITFIELDS. But then the other formats seem unused by theme files so they might be safe to ignore.
On Tue Sep 24 00:44:46 2024 +0000, Zhiyi Zhang wrote:
The regression probably applies to other bitmap compression formats as well. For example, BI_BITFIELDS. But then the other formats seem unused by theme files so they might be safe to ignore.
I guess BI_BITFIELDS should coincide with the 16-bit case you mentioned?
On Tue Sep 24 00:55:32 2024 +0000, Paul Gofman wrote:
I guess BI_BITFIELDS should coincide with the 16-bit case you mentioned?
I think BI_RGB for 16-bit is also valid. Please see https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapi....