Add image to project for printing

I have added images to my project and used as backgrounds for a window… that is done at design time.

How do I access an image inside my project and use it in printing?
I know how to read a .jpg from a folder on the hard drive.
What is the “path” inside the project?

Or is there some other way to do it?

I’d rather store the images inside the project and access them there than have to install them somewhere on the hard drive and hope they stay in place.

Pictures that you dragged into the IDE can be accessed by whatever you named them in the IDE.

As for not having to install them, for quite some time now Xojo hasn’t embedded images inside the executables on Windows, and you can find the images in the [MyApp Resources] folder.

So if I open a file using no path at all but the name of the file like “someimage.jpg”
then it will work automagically on Mac but on Windows we have to add the path to the My App Resources folder?
And if so what is that path?

https://forum.xojo.com/15318-modules-for-you-updated-12-17/0

You don’t even need to know the path if you drag the image into the IDE. You just use the name of the object in the IDE.

g.DrawPicture(someimage, 0, 0)

I have to create picture object to get the height and width because I’m not using DrawPicture but
using BKeeney Shorts to print a report…

Neither of these work with or without quotes.

Dim p as picture = Picture.Open(cover_page.jpg)

Dim p as picture = Picture.Open(“cover_page.jpg”)

If you dragged the image in to the IDE you would reference it as the object name in the IDE.
I’m not quite sure how much more clear I can make that.

You would reference it like any other object in the Navigator.

So much the way you can dim w as new MainWindow you can use dim p as picture = cover_page, and even then you don’t have to do that much because cover_page is already a picture object.

This only applies to images you dragged into the project. Items added via a Copy Files step you must access using the file path, in which case as Michel linked, I would recommend the TPSF module.
https://github.com/devtimi/TPSF

If you dragged the picture into the project look at the NAME of the item in the navigator
The line of code you need is then

 dim p as picture = <name of object in navigator>

Its that simple

And if you used a copy file step to put it in the Resources then you can use GetResource

http://developer.xojo.com/xojo-io-specialfolder$GetResource

Thanks Norman… the IDE drops the .jpg and the official name is without that ending.

Anyway got it working!

DOH!