TBitmap.LoadFromFile lazarus / 39-Graphics ---------------------------------------------------------------------- jfmadre · 2014-03-14 08:51 Hi Everybody, I don't know if my post is in the right topic. I am using Lazarus 1.2 under Windows (vista 32 and W7 64). I have noticed a problem when the FileName (or the path) contains accentuated letter as"é". I have tried conversion to ANSI (using UTF8ToANSI or UTF8ToSys) but in this case it does'nt work. example of code Var    MonImage:TBitmap;   MonFichier:ANSIString; begin    if Opendialog.Execute then       begin           MonFichier:=UTF8ToANSI(OpenDialog.FileName);           // MonFichier:=UTF8ToSys(OpenDialog.FileName); has the same result           MonImage := TBitmap.Create;           MonImage.LoadFromFile(MonFichier); // this instruction causes an issue at run time when the FileName (or path) contains an accentuated letter; (and only with special letters as accentuated)       end; I have also noticed that TStrings.LoadFromFile (like Memo1.Lines.LoadFromFile...)  called whith a similar code works well without issue in the same case. As TFileStream.Create(MonFichier,...) works well also, I have got round the problem using : MonStream:TFileStream; ... MonStream:=TFileStream.Create(MonFichier,fmOpenRead); and then reading the image in the appropriate way in the stream. Is that solution what you name a patch ? (I am quite novice using Lazarus). Thanks if you can solve the problem. ---------------------------------------------------------------------- theo · 2014-03-14 09:47 Doesn't it work if you don't do any conversion at all? Code: [Select]MonImage.LoadFromFile(OpenDialog.FileName); ---------------------------------------------------------------------- jfmadre · 2014-03-14 10:02 No, without conversion it doesn't work in the case if special letters. Whithout conversion it also doesn't work with TStrings.LoadFromFile neither with TFileStream. ---------------------------------------------------------------------- theo · 2014-03-14 10:16 Quote from: jfmadre on March 14, 2014, 11:02:50 amNo, without conversion it doesn't work in the case if special letters. Are you sure? Because conversion is already done in the LCL in "LoadFromFile" of TBitmap (TGraphic). from graphic.inc (Lazarus 1.3 r43836M FPC 2.7.1 x86_64-linux-gtk 2) : Code: [Select]procedure TGraphic.LoadFromFile(const Filename: string); var   Stream: TStream; begin   Stream := TFileStream.Create(UTF8ToSys(Filename), fmOpenRead or fmShareDenyWrite);   try     LoadFromStream(Stream);   finally     Stream.Free;   end; end; ---------------------------------------------------------------------- jfmadre · 2014-03-14 10:27 Thanks for your reply. I am using the new Lazarus 1.2  release and not 1.3 and under windows, that is perhaps the origin of the problem. Is it possible to install this new release without deleting the older, in order to try it ? ---------------------------------------------------------------------- theo · 2014-03-14 10:36 Quote from: jfmadre on March 14, 2014, 11:27:43 amI am using the new Lazarus 1.2  release and not 1.3 and under windows, that is perhaps the origin of the problem. No, this is already in 1.2. It was introduced more than 5 years ago: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/include/graphic .inc?root=lazarus&r1=16216&r2=16236 ---------------------------------------------------------------------- jfmadre · 2014-03-14 12:31 Sorry, you are rigth. I used initially Graphics32 TBitmap32.LoadFromFile that doesn't work when there are accentuated letters. And then try to solve the problem using TBitmap, with a wrong code. (I use now TPicture.LoadFromFile (to be able to open .jpg file) and then Assign the TBitmap32 with the TPicture) Thanks for your help