mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 18:43:51 +00:00
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:
+25
-1
@@ -495,9 +495,15 @@ begin
|
||||
Inc(Row, X1 * 4);
|
||||
for X := X1 to X2 - 1 do
|
||||
begin
|
||||
{$IFDEF DARWIN}
|
||||
Row[1] := Byte((Alpha * R + InvA * Row[1]) div 255);
|
||||
Row[2] := Byte((Alpha * G + InvA * Row[2]) div 255);
|
||||
Row[3] := Byte((Alpha * B + InvA * Row[3]) div 255);
|
||||
{$ELSE}
|
||||
Row[0] := Byte((Alpha * B + InvA * Row[0]) div 255);
|
||||
Row[1] := Byte((Alpha * G + InvA * Row[1]) div 255);
|
||||
Row[2] := Byte((Alpha * R + InvA * Row[2]) div 255);
|
||||
{$ENDIF}
|
||||
Inc(Row, 4);
|
||||
end;
|
||||
end;
|
||||
@@ -513,6 +519,13 @@ var
|
||||
begin
|
||||
if (FSpectrumBitmap = nil) or (FGridBitmap = nil) then Exit;
|
||||
if (W <= 0) or (H <= 0) then Exit;
|
||||
{$IFDEF DARWIN}
|
||||
// On macOS/Cocoa, Canvas writes into a CGBitmapContext; ScanLine reads the
|
||||
// raw backing buffer which is not synced until BeginUpdate is called on the
|
||||
// source bitmap. Canvas.Draw goes through CoreGraphics and sees the live
|
||||
// CGContext, so use it instead of the direct ScanLine copy.
|
||||
FSpectrumBitmap.Canvas.Draw(0, 0, FGridBitmap);
|
||||
{$ELSE}
|
||||
FSpectrumBitmap.BeginUpdate(False);
|
||||
try
|
||||
for Y := 0 to H - 1 do
|
||||
@@ -525,6 +538,7 @@ begin
|
||||
finally
|
||||
FSpectrumBitmap.EndUpdate(False);
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TSpectrumView.DrawADCOverloadOverlay(C: TCanvas; W, H: Integer);
|
||||
@@ -576,9 +590,15 @@ begin
|
||||
if SpPts[Col].Y <= Row then
|
||||
begin
|
||||
Off := Col * 4;
|
||||
{$IFDEF DARWIN}
|
||||
RowPtr[Off+1] := (GradR * Alpha + RowPtr[Off+1] * (200 - Alpha)) div 200;
|
||||
RowPtr[Off+2] := (GradG * Alpha + RowPtr[Off+2] * (200 - Alpha)) div 200;
|
||||
RowPtr[Off+3] := (GradB * Alpha + RowPtr[Off+3] * (200 - Alpha)) div 200;
|
||||
{$ELSE}
|
||||
RowPtr[Off] := (GradB * Alpha + RowPtr[Off] * (200 - Alpha)) div 200;
|
||||
RowPtr[Off+1] := (GradG * Alpha + RowPtr[Off+1] * (200 - Alpha)) div 200;
|
||||
RowPtr[Off+2] := (GradR * Alpha + RowPtr[Off+2] * (200 - Alpha)) div 200;
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
FSpectrumBitmap.EndUpdate(False);
|
||||
@@ -913,7 +933,11 @@ begin
|
||||
FSpectrumBitmap.BeginUpdate(False);
|
||||
for i := 0 to H - 1 do
|
||||
begin
|
||||
AlphaPtr := PByte(FSpectrumBitmap.ScanLine[i]) + 3;
|
||||
{$IFDEF DARWIN}
|
||||
AlphaPtr := PByte(FSpectrumBitmap.ScanLine[i]); // ARGB: alpha at byte 0
|
||||
{$ELSE}
|
||||
AlphaPtr := PByte(FSpectrumBitmap.ScanLine[i]) + 3; // BGRA: alpha at byte 3
|
||||
{$ENDIF}
|
||||
for Yp := 0 to W - 1 do
|
||||
begin
|
||||
AlphaPtr^ := $FF;
|
||||
|
||||
Reference in New Issue
Block a user