Skip to content
Snippets Groups Projects
Commit 42a4e68b authored by Finn Bear's avatar Finn Bear
Browse files

Starter code (java).

parent b89c7b43
No related branches found
No related tags found
No related merge requests found
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class Main {
static final int RESOLUTION = 256;
static BufferedImage image = new BufferedImage(RESOLUTION, RESOLUTION, BufferedImage.TYPE_INT_ARGB);
public static void main(String[] args) {
for (int y = 0; y < RESOLUTION; y++) {
for (int x = 0; x < RESOLUTION; x++) {
writePixel(x, y, 0, 0, 255, 255);
}
}
saveOutput("output.png");
}
static void writePixel(int x, int y, int r, int g, int b, int a) {
int rgba = (a << 24) | (r << 16) | (g << 8) | b;
image.setRGB(x, y, rgba);
}
static void saveOutput(String name) {
File file = new File(name);
try {
ImageIO.write(image, "png", file);
} catch (IOException e) {
System.out.println(e);
}
}
}
\ No newline at end of file
experiments/starter_java/output.png

788 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment