Basic Question about juce::Image

Discussion and support for general JUCE issues

Basic Question about juce::Image

Postby Alatar » Sun Jun 10, 2012 2:26 pm

I have a question about using the juce::Image class. I guess it is both a C++ and a JUCE question.

My application has a background image, that I create programatically. When I resize my application, I create a new image every time, in the "resized()" function.

So I am doing something like this:
Code: Select all
void MainTab::resized()
{
   background = Image(Image::RGB, getWidth(), getHeight(), false);
   //Fill the image with some data
   ...
}

class MainTab  : public Component
{
public:
    void resized();
private:
    Image background;
};   


My question is: am I allowed to do so? Every time I resize the window, a new image is craeted. But where will the Images actually be created? On the stack or on the heap?
And what happens to the "old" images? Who is keeping track of them? Am I leaking memory? Do I maybe need to delete them somehow?
Alatar
JUCE Geek
 
Posts: 29
Joined: Sun Jan 29, 2012 10:44 am
Location: Europe

Re: Basic Question about juce::Image

Postby jules » Sun Jun 10, 2012 2:35 pm

Yes, it's fine. You're not leaking, and don't worry about where the data is stored! It'll be on the heap, or the GPU, or somewhere. Doesn't matter!
User avatar
jules
Fearless Leader
 
Posts: 17209
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK

Re: Basic Question about juce::Image

Postby Alatar » Sun Jun 10, 2012 2:44 pm

Hi Jules,
Thanks for the fast reply!
Alatar
JUCE Geek
 
Posts: 29
Joined: Sun Jan 29, 2012 10:44 am
Location: Europe


Return to General JUCE discussion

Who is online

Users browsing this forum: Google Feedfetcher, sdj and 4 guests