mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 21:00:30 +02:00
* Fix foe 29990
git-svn-id: trunk@33471 -
This commit is contained in:
parent
a7346b2f9d
commit
65e901c844
@ -239,16 +239,13 @@ end;
|
||||
|
||||
function TFPCustomImageReader.CheckContents (Str:TStream) : boolean;
|
||||
var InRead : boolean;
|
||||
P : Int64;
|
||||
begin
|
||||
InRead := assigned(FStream);
|
||||
if not assigned(Str) then
|
||||
raise FPImageException.Create(ErrorText[StrNoStream]);
|
||||
try
|
||||
FSTream := Str;
|
||||
P:=Str.Position;
|
||||
result := InternalCheck (Str);
|
||||
Str.Position:=P;
|
||||
finally
|
||||
if not InRead then
|
||||
FStream := nil;
|
||||
|
@ -123,7 +123,9 @@ var r : integer;
|
||||
reader : TFPCustomImageReader;
|
||||
msg : string;
|
||||
d : TIHData;
|
||||
startPos: Int64;
|
||||
begin
|
||||
startPos := str.Position;
|
||||
with ImageHandlers do
|
||||
try
|
||||
r := count-1;
|
||||
@ -139,6 +141,7 @@ begin
|
||||
try
|
||||
if CheckContents (str) then
|
||||
try
|
||||
str.Position := startPos;
|
||||
FStream := str;
|
||||
FImage := self;
|
||||
InternalRead (str, self);
|
||||
@ -149,6 +152,7 @@ begin
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
str.Position := startPos;
|
||||
end;
|
||||
end;
|
||||
dec (r);
|
||||
|
@ -453,9 +453,12 @@ end;
|
||||
function TFPReaderJPEG.InternalCheck(Str: TStream): boolean;
|
||||
var
|
||||
Buf: array[0..1] of Byte = (0, 0);
|
||||
p: Int64;
|
||||
begin
|
||||
if Str=nil then exit(false);
|
||||
p:=Str.Position;
|
||||
Result := (Str.Read(Buf, 2)=2) and (Buf[0]=$FF) and (Buf[1]=$D8); // byte sequence FFD8 = start of image
|
||||
Str.Position:=p;
|
||||
end;
|
||||
|
||||
constructor TFPReaderJPEG.Create;
|
||||
|
Loading…
Reference in New Issue
Block a user