* Patch from Ondrej Pokorny to change ImageSize to class function (Bug ID 30094)

git-svn-id: trunk@33638 -
This commit is contained in:
michael 2016-05-03 15:15:50 +00:00
parent ce66597df8
commit f65fa34df0
3 changed files with 11 additions and 20 deletions

View File

@ -252,29 +252,20 @@ begin
end;
end;
function TFPCustomImageReader.InternalSize(Str: TStream): TPoint;
class function TFPCustomImageReader.InternalSize(Str: TStream): TPoint;
begin
Result.X:=-1;
Result.Y:=-1;
end;
function TFPCustomImageReader.ImageSize(Str: TStream): TPoint;
var InRead : boolean;
P : Int64;
class function TFPCustomImageReader.ImageSize(Str: TStream): TPoint;
var
P: Int64;
begin
InRead := assigned(FStream);
if not assigned(Str) then
raise FPImageException.Create(ErrorText[StrNoStream]);
try
FStream := Str;
P:=Str.Position;
result := InternalSize (Str);
Str.Position:=P;
finally
if not InRead then
FStream := nil;
end;
P:=Str.Position;
result := InternalSize (Str);
Str.Position:=P;
end;

View File

@ -208,14 +208,14 @@ type
protected
procedure InternalRead (Str:TStream; Img:TFPCustomImage); virtual; abstract;
function InternalCheck (Str:TStream) : boolean; virtual; abstract;
function InternalSize (Str:TStream): TPoint; virtual;
class function InternalSize (Str:TStream): TPoint; virtual;
public
constructor Create; override;
function ImageRead (Str:TStream; Img:TFPCustomImage) : TFPCustomImage;
// reads image
function CheckContents (Str:TStream) : boolean;
// Returns true if the content is readable
function ImageSize(Str:TStream): TPoint;
class function ImageSize(Str:TStream): TPoint;
// returns the size of image in stream without loading it completely. -1,-1 means this is not implemented.
property DefaultImageClass : TFPCustomImageClass read FDefImageClass write FDefImageClass;
// Image Class to create when no img is given for reading

View File

@ -64,7 +64,7 @@ type
protected
procedure InternalRead(Str: TStream; Img: TFPCustomImage); override;
function InternalCheck(Str: TStream): boolean; override;
function InternalSize(Str:TStream): TPoint; override;
class function InternalSize(Str:TStream): TPoint; override;
public
constructor Create; override;
destructor Destroy; override;
@ -451,7 +451,7 @@ begin
end;
end;
function TFPReaderJPEG.InternalSize(Str: TStream): TPoint;
class function TFPReaderJPEG.InternalSize(Str: TStream): TPoint;
var
JInfo: jpeg_decompress_struct;
JError: jpeg_error_mgr;