How do I draw in an off-screen image?

Finlay McWalter

After you've created the offscreen image, you can draw into it by getting the appropriate Graphics object, which you get by calling getGraphics on the offscreen image. Here's a basic example:

Canvas c = new Canvas();
Image i = c.createImage(10, 10); // create offscreen image
Graphics g = i.getGraphics();
g.drawRect(0,1,2,3); // draw into the offscreen image
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.