Graphics: Fix TPicture.LoadFromStream not detecting ico and cur graphics. Issue #41872.

This commit is contained in:
wp_xyz 2025-10-30 19:57:40 +01:00
parent 26fdc1786d
commit 3d86f3b9cf
2 changed files with 12 additions and 0 deletions

View File

@ -1638,6 +1638,7 @@ type
function InternalReleaseBitmapHandle: HBITMAP; override;
function InternalReleaseMaskHandle: HBITMAP; override;
function InternalReleasePalette: HPALETTE; override;
class function IsStreamFormatSupported(Stream: TStream): Boolean; override;
procedure ReadData(Stream: TStream); override;
procedure ReadStream(AStream: TMemoryStream; ASize: Longint); override;
procedure SetMasked(AValue: Boolean); override;

View File

@ -665,6 +665,17 @@ begin
else Result := TIconImage(TSharedIcon(FSharedImage).FImages[FCurrent]).ReleasePalette;
end;
class function TCustomIcon.IsStreamFormatSupported(Stream: TStream): Boolean;
var
Signature: array[0..3] of Byte;
Position: UInt64;
begin
Position := Stream.Position;
Stream.Read(Signature, SizeOf(Signature));
Stream.Position := Position;
Result := (Cardinal(Signature) = GetStreamSignature);
end;
function TCustomIcon.LazarusResourceTypeValid(const ResourceType: string): boolean;
var
ResType: String;