Embedding .jpg file in project

I’m trying to add a .jpg image (foo.jpg, or instance) to my project (so it can be added to a PDF document - I’m using the Einhugur plugin to create the PDF). I’m finding that if I drag the .jpg image file (either alone, or in a folder) to the project navigator (to add it to the project), and then examine the Resources folder in the app, the .jpg file has been changed to a .png file (foo.png).

I didn’t expect this behavior - why does a .jpg file get silently converted to a .png file when it is added to the project via drag/drop?

When I attempt to create a FolderItem reference using SpecialFolder.Resource (using the filename with the .jpg extension), the BinaryStream.Open call (using the FolderItem reference) fails - the embedded project contains foo.png, but the code is expecting foo.jpg.

The other part of this question is… If this is not the proper way to embed a .jpg file in a project, what is the recommended method?

Check out “Copy files” at http://documentation.xojo.com/topics/build_automation/introduction.html .

Thanks! That’s what I was looking for.

You can also trick the IDE. Rename foo.jpg to foo.jpg.dat before dragging into the IDE, and you’ll have an object named foo_jpg which is just binary data, which can be used as a string or memoryblock.

You can also use https://documentation.xojo.com/api/graphics/picture.html#picture-fromdata if you need it back as picture, or just use the bytes as is.

You have a reference (Foo) to use your image. Why bother how it is stored on disk ?

Do this to verify what I wrote above:

a. Add a Canvas to a Window,
b. Select it, then in the Backdrop popup, add the Foo entry.

And you will see the Foo image contents.