Skip to content

Instantly share code, notes, and snippets.

@Bradsta
Created September 26, 2012 01:01
Show Gist options
  • Save Bradsta/3785374 to your computer and use it in GitHub Desktop.
Save Bradsta/3785374 to your computer and use it in GitHub Desktop.
Snippet lol
private static BufferedImage getImage(Canvas canvas) {
BufferedImage image = (BufferedImage) canvas.createImage(canvas.getSize().width, canvas.getSize().height);
Graphics graphics = image.createGraphics();
graphics.setColor(canvas.getBackground());
graphics.fillRect(0, 0, canvas.getSize().width, canvas.getSize().height);
graphics.setColor(canvas.getForeground());
canvas.paint(graphics);
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment