Created
February 15, 2016 20:32
-
-
Save AndrewReitz/ed09237e996c9c0099bf to your computer and use it in GitHub Desktop.
Write Image in Groovy/Java
This file contains 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 javax.imageio.ImageIO | |
import java.awt.image.BufferedImage | |
def image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB) | |
for (x in 0..99) { | |
for (y in 0..99) { | |
int color = (x + y) % 2 == 0 ? 0x000000 : 0xffffff | |
image.setRGB(x, y, color) | |
} | |
} | |
def file = new File('test.png') | |
ImageIO.write(image, 'png', file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment