Skip to content

Instantly share code, notes, and snippets.

@LeRoiDesKiwis
Last active May 31, 2019 12:09
Show Gist options
  • Save LeRoiDesKiwis/b60658bf908768034ffba407530b16a0 to your computer and use it in GitHub Desktop.
Save LeRoiDesKiwis/b60658bf908768034ffba407530b16a0 to your computer and use it in GitHub Desktop.
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