mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 05:29:34 +02:00
* Fix from Werner Pamler to implement missing method. Fixes issue #40685
This commit is contained in:
parent
22de07446d
commit
6c11f048d1
@ -33,9 +33,9 @@ unit FPReadBMP;
|
||||
interface
|
||||
|
||||
{$IFDEF FPC_DOTTEDUNITS}
|
||||
uses FpImage, System.Classes, System.SysUtils, FpImage.Common.Bitmap;
|
||||
uses FpImage, System.Types, System.Classes, System.SysUtils, FpImage.Common.Bitmap;
|
||||
{$ELSE FPC_DOTTEDUNITS}
|
||||
uses FpImage, classes, sysutils, BMPcomn;
|
||||
uses FpImage, types, classes, sysutils, BMPcomn;
|
||||
{$ENDIF FPC_DOTTEDUNITS}
|
||||
|
||||
type
|
||||
@ -68,6 +68,7 @@ type
|
||||
// required by TFPCustomImageReader
|
||||
procedure InternalRead (Stream:TStream; Img:TFPCustomImage); override;
|
||||
function InternalCheck (Stream:TStream) : boolean; override;
|
||||
class function InternalSize (Stream:TStream) : TPoint; override;
|
||||
public
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
@ -516,6 +517,32 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TFPReaderBMP.InternalSize (Stream: TStream): TPoint;
|
||||
var
|
||||
fileHdr: TBitmapFileHeader;
|
||||
infoHdr: TBitmapInfoHeader;
|
||||
n: Int64;
|
||||
StartPos: Int64;
|
||||
begin
|
||||
Result := Point(0, 0);
|
||||
|
||||
StartPos := Stream.Position;
|
||||
try
|
||||
n := Stream.Read(fileHdr, SizeOf(fileHdr));
|
||||
if n <> SizeOf(fileHdr) then exit;
|
||||
if {$IFDEF ENDIAN_BIG}swap(fileHdr.bfType){$ELSE}fileHdr.bfType{$ENDIF} <> BMmagic then exit;
|
||||
n := Stream.Read(infoHdr, SizeOf(infoHdr));
|
||||
if n <> SizeOf(infoHdr) then exit;
|
||||
{$IFDEF ENDIAN_BIG}
|
||||
Result := Point(swap(infoHdr.Width), swap(infoHdr.Height));
|
||||
{$ELSE}
|
||||
Result := Point(infoHdr.Width, infoHdr.Height);
|
||||
{$ENDIF}
|
||||
finally
|
||||
Stream.Position := StartPos;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
ImageHandlers.RegisterImageReader ('BMP Format', 'bmp', TFPReaderBMP);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user