Text not rendered to image


#1

I use the Graphics object to render text to an image but nothing is drawn.


image.SaveAs("C:/Temp/test1.png");
Graphics g(image);
g.setFont(font);
g.setColour( Colours::red );
g.drawSingleLineText( "hello", 0, 0 );
image.SaveAs("C:/Temp/test2.png");
 

Both images are empty.

The font looks like this:

The image looks like this:

The font is not the problem as this also does not work when I change the font to Verdana.

Am I missing a step?

Thanks for any feedback.
Dan


#2

Until you delete or flush a Graphics object, it might not have finished rendering, so you may be saving a half-done image. Also, drawing it with its baseline at (0, 0) means it's probably off the top of your image.