mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-25 15:28:28 +02:00
LCL/TBitmap: TBitmap.LoadFromStream accepts RT_RCDATA bitmap resources. Issue #40529.
This commit is contained in:
parent
32ea407ca3
commit
3b4b6dd3ed
@ -125,25 +125,31 @@ var
|
|||||||
begin
|
begin
|
||||||
if AStream is TResourceStream then
|
if AStream is TResourceStream then
|
||||||
begin
|
begin
|
||||||
FillChar(Header, SizeOf(Header), 0);
|
if TestStreamIsBMP(AStream) then
|
||||||
|
{ Handle the special case of an RC_RTDATA resource which contains a
|
||||||
|
complete, functional TBitmap structure (BitmapFileHeader+BitmapInfoHeader). }
|
||||||
|
inherited LoadFromStream(AStream, ASize)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ Normal case of an RT_BITMAP resource lacking the BitmapFileHeader }
|
||||||
|
FillChar(Header, SizeOf(Header), 0);
|
||||||
|
{ Create a BMP header ordered as it would be on disc, noting that if the CPU
|
||||||
|
is big-endian this will be the "wrong way round" for numeric operations. }
|
||||||
|
{$IFNDEF ENDIAN_BIG}
|
||||||
|
Header.bfType := $4d42;
|
||||||
|
Header.bfSize := SizeOf(Header) + ASize;
|
||||||
|
{$ELSE}
|
||||||
|
Header.bfType := $424d;
|
||||||
|
Header.bfSize := swap(SizeOf(Header) + ASize);
|
||||||
|
{$ENDIF}
|
||||||
|
//Header.bfOffBits := 0; //data follow immediately
|
||||||
|
|
||||||
{ Create a BMP header ordered as it would be on disc, noting that if the CPU
|
S := THeaderStream.Create(AStream, @Header, SizeOf(Header));
|
||||||
is big-endian this will be the "wrong way round" for numeric operations. }
|
try
|
||||||
|
inherited LoadFromStream(S, SizeOf(Header) + ASize);
|
||||||
{$IFNDEF ENDIAN_BIG}
|
finally
|
||||||
Header.bfType := $4d42;
|
S.Free;
|
||||||
Header.bfSize := SizeOf(Header) + ASize;
|
end;
|
||||||
{$ELSE}
|
|
||||||
Header.bfType := $424d;
|
|
||||||
Header.bfSize := swap(SizeOf(Header) + ASize);
|
|
||||||
{$ENDIF}
|
|
||||||
//Header.bfOffBits := 0; //data imediately follows
|
|
||||||
|
|
||||||
S := THeaderStream.Create(AStream, @Header, SizeOf(Header));
|
|
||||||
try
|
|
||||||
inherited LoadFromStream(S, SizeOf(Header) + ASize);
|
|
||||||
finally
|
|
||||||
S.Free;
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user