Basic Question about juce::Image

3 posts / 0 new
Last post
Alatar
Offline
Last seen: 1 month 3 weeks ago
Joined: 29 Jan 2012 - 09:44
Basic Question about juce::Image

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:

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?

jules
Online
Last seen: 6 min 42 sec ago
Joined: 29 Apr 2013 - 18:37
Re: Basic Question about juce::Image

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!

Alatar
Offline
Last seen: 1 month 3 weeks ago
Joined: 29 Jan 2012 - 09:44
Re: Basic Question about juce::Image

Hi Jules,
Thanks for the fast reply!