As part of moving from Windows to Linux I'm porting my applications across. When porting a graphics application that takes pen input (mouse movement) I'm finding the RGBA parameters passed to BGRABitmapTypes.BGRA() need to have their Red and Blue parameters swapped to get correct colors.
I don't want to have my code festooned with,
procedure SetBackgroundColor(pBackgroundColor:TBGRAPixel);
begin
{$IFDEF UNIX}
FBackgroundColor:=BGRA(pBackgroundColor.blue,pBackgroundColor.green,pBackgroundColor.red);
{$ELSE}
FBackgroundColor:=pBackgroundColor;
{$ENDIF}
end;
Noticed in BGRABitmapTypes,
const
{$IFDEF BGRABITMAP_RGBAPIXEL}
TBGRAPixel_RGBAOrder = True;
TBGRAPixel_RedByteOffset = 0;
TBGRAPixel_GreenByteOffset = 1;
TBGRAPixel_BlueByteOffset = 2;
{$ELSE}
{** Order of the channels (when BGRA) }
TBGRAPixel_RGBAOrder = False;
{** Offset of the blue channel (when BGRA) }
TBGRAPixel_BlueByteOffset = 0;
{** Offset of the green channel (when BGRA) }
TBGRAPixel_GreenByteOffset = 1;
{** Offset of the blue channel (when BGRA) }
TBGRAPixel_RedByteOffset = 2;
{$ENDIF}
The correct byte offset for Linux is greyed out i.e. BGRABITMAP_RGBAPIXEL set.
BGRABitmap package was downloaded using Online Package Mangaer and IDE rebuilt with Normal profile.
Have I got my environment setup incorrectly or am I missing something? Everything worked on my computer when I had Windows installed.
My environment,
Computer: Lenovo Laptop
CPU: AMD Ryzen 7 5800H
GPU: RTX 3070
OS: Linux Mint 22.2 Zara
Lazarus IDE: 4.2
FPC: 3.2.2
bglcontrols.lpk: 1.2.0.0
bgrbitmappack.lpk: 11.6.6.0
bgracontrols.lpk: 9.0.2.0
bgrapascalscriptcomponent.lpk: 9.0.2.0