FIX: support app icons on macOS 26.1 #2519

NSBMPFileType to NSPNGFileType

(cherry picked from commit 9200ae0a7c)
This commit is contained in:
rich2014 2025-10-19 21:49:45 +08:00 committed by Alexander Koblov
commit 78ba4aef4b

View file

@ -1152,21 +1152,24 @@ function NSImageToTBitmap( const image:NSImage ): TBitmap;
var
nsbitmap: NSBitmapImageRep;
tempData: NSData;
tempStream: TBlobStream;
tempStream: TBlobStream = nil;
tempBitmap: TPortableNetworkGraphic = nil;
bitmap: TBitmap;
begin
Result:= nil;
if image=nil then exit;
tempStream:= nil;
try
nsbitmap:= NSBitmapImageRep.imageRepWithData( image.TIFFRepresentation );
tempData:= nsbitmap.representationUsingType_properties( NSBMPFileType, nil );
tempData:= nsbitmap.representationUsingType_properties( NSPNGFileType, nil );
tempStream:= TBlobStream.Create( tempData.Bytes, tempData.Length );
tempBitmap:= TPortableNetworkGraphic.Create;
tempBitmap.LoadFromStream( tempStream );
bitmap:= TBitmap.Create;
bitmap.LoadFromStream( tempStream );
bitmap.Assign( tempBitmap );
Result:= bitmap;
finally
FreeAndNil(tempBitmap);
FreeAndNil(tempStream);
end;
end;