Merge branch 'GtkPartialMerge' into 'main'

GTK3: Fixed rendering of images using 32 bits per pixel. Issue #40337.

See merge request freepascal.org/lazarus/lazarus!214
This commit is contained in:
Maxim Ganetsky 2023-06-25 13:21:23 +00:00
commit 0cae5d4eb7
2 changed files with 9 additions and 5 deletions

View File

@ -13,6 +13,7 @@ uses
{$R *.res}
begin
Application.Title := '';
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;

View File

@ -230,8 +230,7 @@ begin
GetMem(NewData, ArawImage.DataSize);
//if (Ridx <> 0) or (Gidx <> 1) or (Bidx <> 2) or (AIdx <> 3) then
if desc.Depth=32 then
if (Ridx <> 0) or (Gidx <> 1) or (Bidx <> 2) or (AIdx <> 3) then
begin
// put components in right order
@ -258,6 +257,8 @@ begin
Inc(DstRowPtr, ARowstride);
Dec(y);
end;
end else begin
System.Move(ArawImage.Data^, NewData^, ArawImage.DataSize);
end;
end
@ -265,11 +266,13 @@ begin
NewData := nil;
// this is only a rough implementation, there is no check against bitsperpixel
case Desc.Depth of
case Desc.BitsPerPixel of
1: ImageFormat := CAIRO_FORMAT_A1;
8: ImageFormat := CAIRO_FORMAT_A8;
else
ImageFormat := CAIRO_FORMAT_ARGB32;
24: ImageFormat := CAIRO_FORMAT_RGB24;
32: ImageFormat := CAIRO_FORMAT_ARGB32;
else
Exit(False);
end;
ARowStride := GetBytesPerLine(Desc.Width, Desc.BitsPerPixel, rileDWordBoundary);
ABitmap := HBitmap(TGtk3Image.Create(NewData, Desc.Width, Desc.Height, ARowStride, ImageFormat,