Browse Source

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

git-svn-id: trunk@33638 -
michael 9 years ago
parent
commit
f65fa34df0

+ 7 - 16
packages/fcl-image/src/fphandler.inc

@@ -252,29 +252,20 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TFPCustomImageReader.InternalSize(Str: TStream): TPoint;
+class function TFPCustomImageReader.InternalSize(Str: TStream): TPoint;
 
 
 begin
 begin
   Result.X:=-1;
   Result.X:=-1;
   Result.Y:=-1;
   Result.Y:=-1;
 end;
 end;
 
 
-function TFPCustomImageReader.ImageSize(Str: TStream): TPoint;
-var InRead : boolean;
-    P : Int64;
+class function TFPCustomImageReader.ImageSize(Str: TStream): TPoint;
+var
+  P: Int64;
 begin
 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;
 end;
 
 
 
 

+ 2 - 2
packages/fcl-image/src/fpimage.pp

@@ -208,14 +208,14 @@ type
     protected
     protected
       procedure InternalRead  (Str:TStream; Img:TFPCustomImage); virtual; abstract;
       procedure InternalRead  (Str:TStream; Img:TFPCustomImage); virtual; abstract;
       function  InternalCheck (Str:TStream) : boolean; virtual; abstract;
       function  InternalCheck (Str:TStream) : boolean; virtual; abstract;
-      function  InternalSize  (Str:TStream): TPoint; virtual; 
+      class function InternalSize  (Str:TStream): TPoint; virtual;
     public
     public
       constructor Create; override;
       constructor Create; override;
       function ImageRead (Str:TStream; Img:TFPCustomImage) : TFPCustomImage;
       function ImageRead (Str:TStream; Img:TFPCustomImage) : TFPCustomImage;
       // reads image
       // reads image
       function CheckContents (Str:TStream) : boolean;
       function CheckContents (Str:TStream) : boolean;
       // Returns true if the content is readable
       // 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.
       // 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;
       property DefaultImageClass : TFPCustomImageClass read FDefImageClass write FDefImageClass;
       // Image Class to create when no img is given for reading
       // Image Class to create when no img is given for reading

+ 2 - 2
packages/fcl-image/src/fpreadjpeg.pas

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