From 3fda0a9be8c999ebc8885ef7ec3a1992020fa27c Mon Sep 17 00:00:00 2001 From: Maxim Ganetsky Date: Mon, 27 Nov 2023 02:28:48 +0300 Subject: [PATCH] LCL-Win32: Fixed blending of semi-transparent pixels of BitBtn glyph. Makes it consistent with TImage and SpeedButtons, issue #38897. --- lcl/interfaces/win32/win32wsbuttons.pp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/win32/win32wsbuttons.pp b/lcl/interfaces/win32/win32wsbuttons.pp index 10376095b5..c97ebd8cd8 100644 --- a/lcl/interfaces/win32/win32wsbuttons.pp +++ b/lcl/interfaces/win32/win32wsbuttons.pp @@ -189,17 +189,19 @@ var OldFontHandle := SelectObject(TmpDC, BitBtn.Font.Reference.Handle); OldTextAlign := GetTextAlign(TmpDC); - // clear background: - // for alpha bitmap clear it with $00000000 else make it solid color for - // further masking if PaintBuffer = 0 then begin + // Make background solid color for further masking. Windows.FillRect(TmpDC, BitmapRect, GetSysColorBrush(COLOR_BTNFACE)); Color := BitBtn.Font.Color; if Color = clDefault then Color := BitBtn.GetDefaultColor(dctFont); SetTextColor(TmpDC, ColorToRGB(Color)); - end; + end + else + // Bitmap has alpha and themes are enabled, therefore BitmapRect is already initialized with $00000000. + // Fill glyph area with solid background to correctly blend semi-transparent pixels, issue #38897. + Windows.FillRect(TmpDC, Rect(XDestBitmap, YDestBitmap, XDestBitmap + glyphWidth, YDestBitmap + glyphHeight), GetSysColorBrush(COLOR_BTNFACE)); if AState <> bsDisabled then begin