Last active
August 29, 2015 13:57
-
-
Save hamnis/9484508 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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