Adding graphics assets to a module

Hi, what’s the process for this. Usually I add them to producer and it build the binary items for me to access.

How do I go about adding these to a module so they’re available to the module?


You can use the BinaryBuilder tool provided in the examples folder of the JUCE repo to generate binary data in .h/.cpp files and namespaces of your choosing. Then just add the generated sources to your module and you should be good to go.

yeah, thx - just found that :slight_smile: actually, i recall using this many moons ago, just forgot about it

Hi, I’ve got some assets but they’ve got some whitespace in them so don’t render as I want.


Is there an easy way to process this out or do I need to go and trim the assets by hand?


I don’t see an auto crop method implemented. But an awkward workflow might work:

Create a DrawableImage from the image
call getOutlineAsPath()
get the bounding box of that path

juce::DrawableImage drawable;
drawable.setImage (image);
auto path = drawable.getOutlineAsPath();
auto cropped = image.getClippedImage (path.getBounds());

Let me know if that works, I am curious :wink:

N.B. 1: instead of BinaryBuilder you can use Projucer from commandline to create BinaryData
N.B. 2: You could probably batch process your images with gimp/script-fu, but I never used it myself

Interesting idea, but no joy. Path comes back with a bounds of 0,0,0,0

Ah drat, thanks for trying…
I think writing a marching cubes algorithm or something similar to find the bounding box is not too hard. Annoying that it doesn’t exist yet.

1 Like

I’ve always just trimmed them manually when needed, so I’m not sure what the easiest approach would be for automating this. In my case, I’m usually using fairly simple SVGs so opening them in Inkscape and hitting ctrl+shift+R does the trick. Inkscape has a CLI mode that might make things easier for batch processing if you’re dealing with SVGs:

inkscape --export-plain-svg --export-filename Output.svg --export-area-drawing Input.svg

1 Like