Loading and displaying an image from a path


I want to let the user browse to an image file, which is then displayed in an image button.

I’ve seen on the JUCE Demo under components: Dialog Boxes, the ‘Load’ File Browser With Image Preview does what I want so have adapted code from there. This results in the chosen image path being put in a string.

I’m not sure how I get from a path string to this being stored somewhere, somehow and then being displayed in an imagebutton using .setImages. I’ve looked at the Image and File classes and I possibly might use Image::getFromFile() and/or File::loadFileAsString().

Thanks for any help


Something like :

Image img=ImageFileFormat::loadFrom(myFileChooser.getResult());