Fix macOS pixel format: use ARGB byte order in all raw ScanLine blending

On macOS Cocoa, TBitmap.pf32bit stores pixels in ARGB order
   (byte0=A, byte1=R, byte2=G, byte3=B) rather than BGRA used on
   Linux/Windows. All raw ScanLine pixel blending and channel mapping
   is now guarded with { DARWIN} to use the correct offsets.

   Also fix PortAudio library discovery on macOS: probe .dylib names
   (including Homebrew paths) before falling through to .so/.dll.
This commit is contained in:
Uladzimir Karpenka
2026-05-28 21:47:54 +03:00
parent 4f127a30ad
commit a02d35fcce
8 changed files with 132 additions and 24 deletions
+11 -1
View File
@@ -173,13 +173,23 @@ begin
Inc(DstRow, DstX * 4);
for X := SX0 to SX1 - 1 do
begin
// KEY_COLOR is clFuchsia in pf32bit B,G,R order.
{$IFDEF DARWIN}
// ARGB layout: byte0=A, byte1=R, byte2=G, byte3=B
if not ((SrcRow[1] = $FF) and (SrcRow[2] = $00) and (SrcRow[3] = $FF)) then
begin
DstRow[1] := Byte((Alpha * SrcRow[1] + InvA * DstRow[1]) div 255);
DstRow[2] := Byte((Alpha * SrcRow[2] + InvA * DstRow[2]) div 255);
DstRow[3] := Byte((Alpha * SrcRow[3] + InvA * DstRow[3]) div 255);
end;
{$ELSE}
// BGRA layout: byte0=B, byte1=G, byte2=R
if not ((SrcRow[0] = $FF) and (SrcRow[1] = $00) and (SrcRow[2] = $FF)) then
begin
DstRow[0] := Byte((Alpha * SrcRow[0] + InvA * DstRow[0]) div 255);
DstRow[1] := Byte((Alpha * SrcRow[1] + InvA * DstRow[1]) div 255);
DstRow[2] := Byte((Alpha * SrcRow[2] + InvA * DstRow[2]) div 255);
end;
{$ENDIF}
Inc(SrcRow, 4);
Inc(DstRow, 4);
end;