On MacOS, drawing on a Tbitmap.Canvas changes R, G, B values

Issue #227 resolved
dthoiron created an issue

Hi,

When I draw on the canvas of a 24bit Tbitmap with a certain brush color (e.g. clRed, R=255, G=0, B=0), the color values are slightly shifted on MacOS. clRed gives these values : R=251, G=0, B=7.

Here is some code example to reproduce the issue (put a TButton called TestButton and a TImage containing a 24bit bitmap on Form1) :

procedure TForm1.TestButtonClick(Sender: TObject);
var
j: Integer;
TempBmpPixels: Array [0..32767] of pRGBArray;
begin
for j := 0 to TestImage.Picture.Bitmap.height - 1 do
begin
TempBmpPixels[j] := TestImage.Picture.Bitmap.ScanLine[j];
end;
TestImage.Picture.Bitmap.Canvas.Brush.Color:=clRed;
TestImage.Picture.Bitmap.Canvas.FillRect(TestImage.ClientRect);
Showmessage(inttostr(TempBmpPixels[100,100].rgbtRed)+' '+inttostr(TempBmpPixels[100,100].rgbtGreen)+' '+inttostr(TempBmpPixels[100,100].rgbtBlue));
end;

Attached are the screenshots on Windows 10 and on MacOs Big Sur.

I guess this is due to some color profile correction on the Mac, but how can I avoid this?

Best regards

Comments (3)

  1. Eugene Kryukov repo owner

    We are doing big internal refactoring of graphics (GDI, GDI+) in preparing to support mobile & HiDPI. We don’t have such behavior on our new internal build. We are going to release CrossVcl 1.50 in a month.

  2. Log in to comment