Splashscreen image from a resource?



Ive just started using Juce for a project I have in mind. Its my first attempt at C++, but I have a wealth of other programming experience. I understand OO, classes, pointers, references, etc so I thought I would give it a go, since Juce provides a lot of what I will need, which will make the task much easier.

Ive started building the app from the ground up. Right now I dont have much more than an empty main window, but before I try and tackle menu bars and the like, Im trying to sort out the Splash screen.

I’d like to grab the splash screen image from a resource in vs2010 rather than from a file. I dont want to have the image on disk as part of the application and would rather it be embedded in the application itself, where its safe and sound. The problem is, how do I then reference it and load it into the ImageCache? I assume I would use ImageCache::getFromMemory() but Im having trouble figuring how to get the data I need to pass into the method, in order to have it load the image from a resource. I guess it would be handy if ImageCache could load resources directly but I havnt seen anything obvious in the API docs.

Ive seen examples on the net reading the image data with LoadBitmap() and I could probably get the size once I have it loaded, but this is Windows specific. Is there a portable way to achieve this? A windows only solution is fine, but I thought since Im using a multi-platform framework, I should make my code as portable as I can.

Im using Juce 2.0, and the image is a PNG stored as a bitmap resource in my project.

Any help, examples, or pointers of where to look, would be much appreciated. Thanks.




Thanks for the blindingly fast reply… That looks like what I need. Thanks for the response :slight_smile:


You don’t need to use binarybuilder - the introjucer will automatically do the same job for any images you add to your project. Have a look at the demo app, that uses a few embedded resources in that way.


Thanks Jules,

I did notice those in the source just before, but assumed they must have come from the BinaryBuilder. As it turns out, I had the splash screen up and running about 15 or 20 mins after TheVinn’s post :slight_smile:

I hadnt looked at the demo app until today (after discovering BinaryBuilder) partly because when I used Introjucer to set up my project, it went ahead and downloaded the newest Juce modules, and when I tried later to compile the other builds, they (the Jucer, and the demo app in particular) would not compile. Ive only been at this a couple of days, and just figured out what the problem was today, so I unpacked the 2.0 release again and have them compiled now.

I spent the next several hours playing with the Jucer… if only it built menu bars (my next task). Those look scary for the moment. I havnt quite got my head around the API yet.

Thanks for the advice… I’ll take another look at that part of the Introjucer. :slight_smile: