Search code examples
c++xcodejuce

JUCE image buttons without embedding files


Is there anyway to just include a file from a relative path using JUCE? Between graphics, up and down button states, I have about 40 images and trying to create them through the ProJucer causes thousands of lines (over 20,00 in this particular situation) to be generated and embedded in my GUI component. This is causing huge performance issues in Xcode for me. Is it possible to just include the files via relative path and save all that embedded code? The .cpp is so large even GitHub says they are too large to display. Any help is greatly appreciated.


Solution

  • To use embedded images in your project, but not have them taking up space inside each component's .cpp file as generated by the Projucer, do this instead:

    • Add the image files to the Projucer project itself.

      (images added to Projucer)

    When you save the Projucer project, the image data will be added to your project's BinaryData.h/cpp file that's located in the JuceLibraryCode directory.

    • When you want to create the ImageButton, instead of selecting 'create a new image resource' (which would put the binary data into your component's source directly), select the BinaryData resource that you created above:

    select the image resource