Skip to content

Instantly share code, notes, and snippets.

@hamnis
Last active August 29, 2015 13:57
Show Gist options
  • Save hamnis/9484508 to your computer and use it in GitHub Desktop.
Save hamnis/9484508 to your computer and use it in GitHub Desktop.
import java.awt.{Color, Graphics2D}
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
public class Main {
//Does not deal with double buffering, and writing on servers which are headless.
public BufferedImage createBlackImage(int width, int height) {
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setBackground(Color.BLACK);
graphics.drawRect(0, 0, width, height);
return image;
}
public static void main(String[] args) {
ImageIO.write(createBlackImage(100, 100), "png", new java.io.File(args[0]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment