From 242d0d20fa6bd486a538be7f798a08711d9c1007 Mon Sep 17 00:00:00 2001 From: jesus Date: Tue, 30 Nov 2010 18:43:04 +0000 Subject: [PATCH] LazReport, support for images stored in old reports where they were stored as bitmaps git-svn-id: trunk@28576 - --- components/lazreport/source/lr_class.pas | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/components/lazreport/source/lr_class.pas b/components/lazreport/source/lr_class.pas index d4b982360d..60bc3119a8 100644 --- a/components/lazreport/source/lr_class.pas +++ b/components/lazreport/source/lr_class.pas @@ -4287,19 +4287,19 @@ begin inherited LoadFromXML(XML, Path); Shared:=XML.GetValue(Path+'Picture/Shared/Value',false); + b := XML.GetValue(Path+'Picture/Type/Value', pkNone); + Ext := XML.GetValue(Path+'Picture/Type/Ext', ''); M := nil; - b := XML.GetValue(Path+'Picture/Type/Value', pkNone); - if b=pkAny then begin - Ext := XML.GetValue(Path+'Picture/Type/Ext', ''); - if Ext='' then begin - GetPictureStream; - Graphic := StreamToGraphic(M); - end else - Graphic := ExtensionToGraphic(Ext) - end + if (b=pkAny) and (Ext<>'') then + Graphic := ExtensionToGraphic(Ext) else - Graphic := PictureTypeToGraphic(b); + if (b>pkBitmap) then + Graphic := PictureTypeToGraphic(b) + else begin + GetPictureStream; + Graphic := StreamToGraphic(M); + end; Picture.Graphic := Graphic; if Graphic <> nil then @@ -4308,8 +4308,12 @@ begin if M=nil then GetPictureStream; try - M.Position := 0; - Picture.Graphic.LoadFromStream(M); + try + M.Position := 0; + Picture.Graphic.LoadFromStream(M); + except + ShowMessage('Unknown Image Format!'); + end; finally M.Free; end; @@ -4517,6 +4521,12 @@ function TfrPictureView.StreamToGraphic(M: TMemoryStream): TGraphic; end; begin + + if M=nil then begin + result := nil; + exit; + end; + M.Position := 0; if TestStreamIsBMP(M) then