Recent

Author Topic: Can't load or open file macOS Catalina - Lazarus IDE v2.0.10  (Read 239 times)

norosz123456

  • Newbie
  • Posts: 2
Can't load or open file macOS Catalina - Lazarus IDE v2.0.10
« on: October 25, 2020, 12:27:36 pm »
Hello.

I tried to load a picture for my Image object. On Windows it works, but on Mac I get every time this error message:

--- Unable to open file "background.png" ---

I tried .jpg and .bmp too... does not works.
It is a simple code, but it does not works on Mac:

Image1.Picture.LoadFromFile('background.png');

I tried create a new file (.csv file) with SaveDialog and it worked. I just can't open or load - read files.

If somebody can, pls help me. Thank you!

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1053
  • Former Delphi 1-7, 10.2 User
Re: Can't load or open file macOS Catalina - Lazarus IDE v2.0.10
« Reply #1 on: October 26, 2020, 04:45:53 am »
This works for me on Catalina:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   Image1.Picture.LoadFromFile('/Users/trev/Documents/Bug_Test/smiley.jpg');
  4. end;

or

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   OpenDialog1.Execute;
  4. end;
  5.  
  6. procedure TForm1.OpenDialog1Close(Sender: TObject);
  7. begin
  8.   Image1.Picture.LoadFromFile(OpenDialog1.FileName);
  9. end;  


Alternatively, if the image is going to be part of the application's resources, see Locating the macOS application resources directory.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

norosz123456

  • Newbie
  • Posts: 2
Re: Can't load or open file macOS Catalina - Lazarus IDE v2.0.10
« Reply #2 on: October 26, 2020, 02:47:12 pm »
It is working now! Thank you very much!  :D :)

 

TinyPortal © 2005-2018