From cc7e8f55c4fc4eb47f910be7d77d101a2012b566 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sun, 27 Jul 2014 00:25:28 +0100 Subject: LoadImage_XXX() methods never did OS Encoding of the filenames It now correctly encodes the UTF-8 filename to the OS Encoding. The filename parameter is now also a TfpgString type to denote that it is expected to be a UTF-8 encoded string. --- src/corelib/fpg_imgfmt_bmp.pas | 4 ++-- src/corelib/fpg_imgfmt_jpg.pas | 23 ++++++++++++----------- src/corelib/fpg_imgfmt_png.pas | 6 +++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/corelib/fpg_imgfmt_bmp.pas b/src/corelib/fpg_imgfmt_bmp.pas index 00637f3b..fe827405 100644 --- a/src/corelib/fpg_imgfmt_bmp.pas +++ b/src/corelib/fpg_imgfmt_bmp.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2014 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -64,7 +64,7 @@ begin if not fpgFileExists(AFileName) then Exit; //==> - AssignFile(AFile, AFileName); + AssignFile(AFile, fpgToOSEncoding(AFileName)); FileMode := fmOpenRead; // read-only Reset(AFile); AImageDataSize := FileSize(AFile); diff --git a/src/corelib/fpg_imgfmt_jpg.pas b/src/corelib/fpg_imgfmt_jpg.pas index 33704643..4fe67692 100644 --- a/src/corelib/fpg_imgfmt_jpg.pas +++ b/src/corelib/fpg_imgfmt_jpg.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2014 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -34,10 +34,11 @@ type EJPEG = class(Exception); procedure ReadImage_JPG(img: TfpgImage; bmp: TStream; const AScale: integer = 1); -function LoadImage_JPG(const AFileName: String; const AScale: integer = 1): TfpgImage; +function LoadImage_JPG(const AFileName: TfpgString; const AScale: integer = 1): TfpgImage; implementation uses + fpg_utils, {PASJPG10 library} jmorecfg, jpeglib, @@ -360,21 +361,21 @@ begin img.UpdateImage; end; -function LoadImage_JPG(const AFileName: String; const AScale: integer): TfpgImage; +function LoadImage_JPG(const AFileName: TfpgString; const AScale: integer): TfpgImage; var inFile: TStream; begin Result := nil; - if not FileExists(AFileName) then + if not fpgFileExists(AFileName) then Exit; //==> - inFile:=TFileStream.Create(AFileName,fmOpenRead); - try - Result:=TfpgImage.Create; - ReadImage_JPG(Result, inFile, AScale); - finally - inFile.Free; - end; + inFile := TFileStream.Create(fpgToOSEncoding(AFileName), fmOpenRead); + try + Result := TfpgImage.Create; + ReadImage_JPG(Result, inFile, AScale); + finally + inFile.Free; + end; end; diff --git a/src/corelib/fpg_imgfmt_png.pas b/src/corelib/fpg_imgfmt_png.pas index d9683bbe..3148a5b4 100644 --- a/src/corelib/fpg_imgfmt_png.pas +++ b/src/corelib/fpg_imgfmt_png.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2014 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -78,7 +78,7 @@ begin try PNGReader := TFPReaderPNG.Create; try - imga.LoadFromFile(AFileName, PNGReader); // auto size image + imga.LoadFromFile(fpgToOSEncoding(AFileName), PNGReader); // auto size image finally PNGReader.Free; end; @@ -165,7 +165,7 @@ begin // Calculated to fit the image within required size: xlocal, ylocal imga := TFPMemoryImage.Create(0, 0); try - imga.LoadFromFile(AFileName, TFPReaderPNG.Create); // auto size image + imga.LoadFromFile(fpgToOSEncoding(AFileName), TFPReaderPNG.Create); // auto size image except imga := nil; imgb := nil; -- cgit v1.2.3-70-g09d2