summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpg_imgfmt_png.pas8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/fpg_imgfmt_png.pas b/src/corelib/fpg_imgfmt_png.pas
index c95150e4..d9683bbe 100644
--- a/src/corelib/fpg_imgfmt_png.pas
+++ b/src/corelib/fpg_imgfmt_png.pas
@@ -68,6 +68,7 @@ end;
function LoadImage_PNG(const AFileName: TfpgString): TfpgImage;
var
imga: TFPCustomImage;
+ PNGReader: TFPReaderPNG;
begin
Result := nil;
if not fpgFileExists(AFileName) then
@@ -75,7 +76,12 @@ begin
imga := TFPMemoryImage.Create(0, 0);
try
- imga.LoadFromFile(AFileName, TFPReaderPNG.Create); // auto size image
+ PNGReader := TFPReaderPNG.Create;
+ try
+ imga.LoadFromFile(AFileName, PNGReader); // auto size image
+ finally
+ PNGReader.Free;
+ end;
except
imga := nil;
end;