Getting a picture stored in the project given its name

I have a bunch of pictures that will come along with the app. I have dragged a few (just testing now) into the project.

What I need to do is get access to a picture given its name. Is this possible?

You should be able to reference them directly:

Dim p As Picture = nameOfPicture 

Or

g.DrawPicture(nameOfPicture, 0, 0)
1 Like

The problem is that I have the name of the picture as a String as part of the other data it goes with.

Write a Select Case statement in a helper method that takes the string as an input and returns a picture for each matching string using the syntax that Andrew recommended.

If you have many big pictures, the correct way to do this is using an Asset Catalog. The App store will automatically trim asset catalogs to make your app thinner on @2x / @3x devices.

Unfortunately Xojo doesn’t support creating an asset catalog, although it does create one for the app’s icon.

Took me a few years to understand how to create an asset catalog and use it, took 20 minutes to set up using AI the last time I needed it.


In Xojo you can copy all pictures to your app using a build step and then open them using SpecialFolder.Resource