Last active
May 31, 2019 12:09
-
-
Save LeRoiDesKiwis/b60658bf908768034ffba407530b16a0 to your computer and use it in GitHub Desktop.
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
package fr.leroideskiwis.allcolors; | |
import javax.imageio.ImageIO; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
public class Main{ | |
public Main() throws IOException { | |
BufferedImage image = new BufferedImage(4096, 4096, 1); | |
int i = 0; | |
for (int x = 0; x < image.getWidth(); x++) { | |
for (int y = 0; y < image.getHeight(); y++) { | |
image.setRGB(x, y, i); | |
i++; | |
} | |
//System.out.println("Repainting with x="+x+" and i="+i+" and hex="+Integer.toHexString(i)); | |
} | |
ImageIO.write(image, "png", getFile("./image", "png")); | |
} | |
private File getFile(String path, String extension){ | |
File file = new File(path+"."+extension); | |
for(int i = 0; file.exists(); i++){ | |
file = new File(path+i+"."+extension); | |
} | |
return file; | |
} | |
public static void main(String[] args) throws IOException { | |
new Main(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment