Offscreen Context?

Hello again. Can anyone tell me how I can render to an image in memory, the same way you would a normal screen? I used to be able to do this with the old VSTGUI code with an ‘COffscreenContext’ - is it possible using Juce? BTW I don’t want an OpenGL context, I just want to draw lines and text into it.
Thanks,
Dave.

Hi,
you can simply create a Graphics context and use the normal paint functions on that:

Image myImage (Image::RGBA, 600, 400, false);
Graphics g (myImage);
g.fillAll (Colours::black);
g.setColour (Colours::red);
g.drawEllipse (300, 200, 250, 150, 10);

…and so on…

HTH

2 Likes

Brilliant! That’s super easy. Thanks for the quick reply. I presume that all the alpha rendering works OK in it?

Yes, if you chose the Pixelformat to be RGBA. RGB exists as well, in that case all would be opaque.
Note, there exist also the special colours transparentWhite and transparentBlack, if you need them…