From 05d2879059e1284598bc43c1a2ee8bda341a9396 Mon Sep 17 00:00:00 2001 From: jesus Date: Wed, 22 Jan 2014 08:13:55 +0000 Subject: [PATCH] LazReport, handle db image streams the same way as dbimage git-svn-id: trunk@43780 - --- components/lazreport/source/lr_class.pas | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/components/lazreport/source/lr_class.pas b/components/lazreport/source/lr_class.pas index 8023c7ba7d..1d4b20859e 100644 --- a/components/lazreport/source/lr_class.pas +++ b/components/lazreport/source/lr_class.pas @@ -4983,10 +4983,9 @@ var GraphExt: string; gc: TGraphicClass; AGraphic: TGraphic; + CurPos: Int64; function LoadImageFromStream: boolean; - var - CurPos: Int64; begin result := (s<>nil); if result then @@ -5021,27 +5020,32 @@ begin if assigned(CurReport.OnDbImageRead) then CurReport.OnDBImageRead(Self, s, GraphExt) else - if LoadImageFromStream then - exit; - - try - if GraphExt='' then begin + begin + CurPos := s.Position; + try GraphExt := s.ReadAnsiString; if Length(GraphExt)>10 then GraphExt := ''; // even 10 would mean we have a false positive + except + s.Position := CurPos; + GraphExt := ''; end; + end; + if GraphExt<>'' then begin gc := GetGraphicClassForFileExtension(GraphExt); if assigned(gc) then begin AGraphic := gc.Create; AGraphic.LoadFromStream(s); Picture.Assign(AGraphic); - end; - - except + end else + GraphExt := ''; end; + if GraphExt='' then + LoadImageFromStream; + finally s.Free; AGraphic.Free;