From e4592856f24e69bfb7631f9bf6d022058a16d383 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 23 Sep 2013 17:03:05 +0100 Subject: Fixes GitHub Issue #9 (15bit color conversion under X11) https://github.com/graemeg/fpGUI/issues/9 Thanks to UAPLY for debugging the issue and supplying the solution. Much appreciated. --- src/corelib/x11/fpg_x11.pas | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas index 92eaf454..c7a1b865 100644 --- a/src/corelib/x11/fpg_x11.pas +++ b/src/corelib/x11/fpg_x11.pas @@ -488,6 +488,13 @@ begin Result := Result or ((rgb and $F80000) shr 8); end; +function ConvertTo555Pixel(rgb: longword): word; +begin + Result := (rgb and $F8) shr 3; + Result := Result or ((rgb and $F800) shr 6); + Result := Result or ((rgb and $F80000) shr 9); +end; + function fpgColorToX(col: TfpgColor): longword; var xc: TXColor; @@ -499,6 +506,8 @@ begin Result := c and $FFFFFF { No Alpha channel information } else if xapplication.DisplayDepth = 16 then Result := ConvertTo565Pixel(c) + else if (xapplication.DisplayDepth = 15) then + Result := ConvertTo555Pixel(c) else begin c := col; -- cgit v1.2.3-70-g09d2