mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-02-25 07:48:46 +01:00
LCL: added TPicture.LoadFromStreamWithFileExt
git-svn-id: trunk@13528 -
This commit is contained in:
parent
cf4a33912a
commit
d3a6947d40
@ -817,6 +817,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure LoadFromFile(const Filename: string);
|
||||
procedure SaveToFile(const Filename: string);
|
||||
procedure LoadFromStreamWithFileExt(Stream: TStream; const FileExt: string);
|
||||
procedure LoadFromClipboardFormat(FormatID: TClipboardFormat);
|
||||
procedure LoadFromClipboardFormatID(ClipboardType: TClipboardType;
|
||||
FormatID: TClipboardFormat);
|
||||
|
||||
@ -512,6 +512,33 @@ begin
|
||||
if FGraphic <> nil then FGraphic.SaveToFile(Filename);
|
||||
end;
|
||||
|
||||
procedure TPicture.LoadFromStreamWithFileExt(Stream: TStream;
|
||||
const FileExt: string);
|
||||
var
|
||||
GraphicClass: TGraphicClass;
|
||||
NewGraphic: TGraphic;
|
||||
ok: Boolean;
|
||||
begin
|
||||
GraphicClass := FindGraphicClassWithFileExt(FileExt);
|
||||
|
||||
NewGraphic := GraphicClass.Create;
|
||||
ok:=false;
|
||||
try
|
||||
NewGraphic.OnProgress := @Progress;
|
||||
DebugLn(['TPicture.LoadFromStreamWithFileExt ',Stream.Position,' ',Stream.Size,' ',DbgSName(Stream)]);
|
||||
NewGraphic.LoadFromStream(Stream);
|
||||
ok:=true;
|
||||
finally
|
||||
// this try..finally construction will in case of an exception
|
||||
// not alter the error backtrace output
|
||||
if not ok then NewGraphic.Free;
|
||||
end;
|
||||
FGraphic.Free;
|
||||
FGraphic := NewGraphic;
|
||||
FGraphic.OnChange := @Changed;
|
||||
Changed(Self);
|
||||
end;
|
||||
|
||||
procedure TPicture.LoadFromClipboardFormat(FormatID: TClipboardFormat);
|
||||
begin
|
||||
LoadFromClipboardFormatID(ctClipboard,FormatID);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user