Does image exist

if I need an image in my app, I drag it from finder into the app.
in the app I use it as canvas.backdrop.
if image exists, all is ok.
if the image does not exist in my app the canvas is empty.

How can I find out if the image exists in my app ?
Or is there another way how to use / store images in an app ?

Xojo 2020.R2

If your app is using ‘supports HiDPI’, you are expected to provide 3 versions.
Have you checked whether all 3 resolutions exist for that image?

Not sure if 3 is needed. As far as I know, there is no system using the 4x (yet). So only 1x and 2x is enough.

Firstly I would like to know if there is a way to check for the existence
of the image in my app, I might have forgotten to drag the image into my app.

Nor me, to be fair.
But if the image is ‘dragged into the IDE’, then it cant be ‘missing’ by any means I can imagine

Let’s see if any more info is forthcoming

If you forgot to do that, it won’t compile.
You refer to the image by name.
No image, you get undeclared variable style messages.

that’s true, Jeff,
thanks

You can check if your Canvas1.Backdrop = Nil (whatever name Canvas1 is
).

You can create a Picture, set some error text in it and at run time display that error Picture when the Canvas Backrop is empty ( = Nil).

That said, until nowadays and afaik, an image dropped into a project is stored in the project. That is why your project file is so large, takes time to be opened and saved.
If you export your project as xml and look at the xml, you will “see” the image contents (as hex, the last time I checked).

Now, this is your project and you are allowed to drop images into it (or open them using a FolderItem, once you saved them in an Images folder).

Emilie, you don’t know how big my project is, in fact it is 26MB, is that big ?
What’s another way to store my images ?

Take your time and put all images in an “Images” folder.

Then you load “silently” (no dialog) all the images at Open Event time.

Of course, you have to move the “Images” to SpecialFolder.ApplicationSupport (your folder there) at application first run time, then at each following run, you check if the folder is there


thanks Emilie, will see if I can find an example somewhere 


Is that the project size, or compiled application size?

This is exactly what Xojo is doing anyway.
Images (and other items) you drag into the IDE end up in the resources subfolder.
They are loaded silently from there , when referred to in code.

1 Like

compiled application size, I guess

  1. Emile (not Emilie).

  2. If this is Project, you can follow my previous advice to store the image outside of the project


  3. If this is the size of the application: nothing can be done (more or less).
    The application needs the images (built-in the application or in a Support folder change nothing for the whole size).

26MB ? not so large nowadays


Hint to copy data inside the Application: Build Automation

I was thinking about how to do it and discovered SF Symbols.
I use them now instead of icons, looks really cool.