From 9cf9304d031cc43f7f1fa05683d197d14c480767 Mon Sep 17 00:00:00 2001 From: dmitry Date: Fri, 16 Aug 2019 20:13:57 +0000 Subject: [PATCH] cocoa: returning alpha multiplied colors in NSColorToRGB git-svn-id: trunk@61710 - --- lcl/interfaces/cocoa/cocoautils.pas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lcl/interfaces/cocoa/cocoautils.pas b/lcl/interfaces/cocoa/cocoautils.pas index 57a43f3ab5..367cbac826 100644 --- a/lcl/interfaces/cocoa/cocoautils.pas +++ b/lcl/interfaces/cocoa/cocoautils.pas @@ -365,9 +365,14 @@ begin end; function NSColorToRGB(const Color: NSColor): TColorRef; inline; +var + alpha: CGFloat; begin + // TColorRef doesn't bear an alpha channel information. + // Thus RGB needs to be multiplied by it. + alpha := Color.alphaComponent; with Color do - Result := RGBToColorFloat(redComponent, greenComponent, blueComponent); + Result := RGBToColorFloat(redComponent*alpha, greenComponent*alpha, blueComponent*alpha); end; function NSColorToColorRef(const Color: NSColor): TColorRef;