Using images for background of component [SOLVED]


#1

Hi,
I have a simple question: how can I use images (for example for background of component).
Thanks for reply


#2

Where you have a class member

Image    m_Background;

Load the image in the class constructor, then in paint():

void CYourComponent::paint (Graphics& g)
{
    if (m_Background.isValid())
        g.drawImageAt (m_Background, 0, 0);

    :
}

Rail


#3

Yes I know, but I do not know how to load an image (for example png) to Image class.


#4

static Image ImageCache::getFromFile (const File & file)

https://bill-auger.github.io/JUCE/doxygen/doc/classImageCache.html#acc266a65cf61dd0a2f68e68840b4a5c4

Rail


#5

Thanks for your reply, I found what I need.

Image splash = ImageFileFormat::loadFrom(BinaryData::splashscreen_png, (size_t) BinaryData::splashscreen_pngSize);

I apologize for the confusion