Recent

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

norosz123456

  • Newbie
  • Posts: 3
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: 2020
  • 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.

norosz123456

  • Newbie
  • Posts: 3
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