mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-26 14:08:18 +02:00
LCL/TBitmap: TBitmap.LoadFromStream accepts RT_RCDATA bitmap resources. Issue #40529.
This commit is contained in:
parent
32ea407ca3
commit
3b4b6dd3ed
@ -125,11 +125,16 @@ var
|
|||||||
begin
|
begin
|
||||||
if AStream is TResourceStream then
|
if AStream is TResourceStream then
|
||||||
begin
|
begin
|
||||||
|
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);
|
FillChar(Header, SizeOf(Header), 0);
|
||||||
|
{ Create a BMP header ordered as it would be on disc, noting that if the CPU
|
||||||
{ 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. }
|
is big-endian this will be the "wrong way round" for numeric operations. }
|
||||||
|
|
||||||
{$IFNDEF ENDIAN_BIG}
|
{$IFNDEF ENDIAN_BIG}
|
||||||
Header.bfType := $4d42;
|
Header.bfType := $4d42;
|
||||||
Header.bfSize := SizeOf(Header) + ASize;
|
Header.bfSize := SizeOf(Header) + ASize;
|
||||||
@ -137,7 +142,7 @@ begin
|
|||||||
Header.bfType := $424d;
|
Header.bfType := $424d;
|
||||||
Header.bfSize := swap(SizeOf(Header) + ASize);
|
Header.bfSize := swap(SizeOf(Header) + ASize);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
//Header.bfOffBits := 0; //data imediately follows
|
//Header.bfOffBits := 0; //data follow immediately
|
||||||
|
|
||||||
S := THeaderStream.Create(AStream, @Header, SizeOf(Header));
|
S := THeaderStream.Create(AStream, @Header, SizeOf(Header));
|
||||||
try
|
try
|
||||||
@ -145,6 +150,7 @@ begin
|
|||||||
finally
|
finally
|
||||||
S.Free;
|
S.Free;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
inherited LoadFromStream(AStream, ASize);
|
inherited LoadFromStream(AStream, ASize);
|
||||||
|
Loading…
Reference in New Issue
Block a user