50 lines
1.6 KiB
Java
50 lines
1.6 KiB
Java
package de.darkress.pixelfood;
|
|
|
|
import javax.imageio.ImageIO;
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.*;
|
|
import java.net.*;
|
|
|
|
class Main
|
|
{
|
|
private final int PORT = 1234;
|
|
private final String HOSTNAME = "localhost";
|
|
private byte[] message;
|
|
|
|
public static void main(String[] args) {
|
|
try {
|
|
// Read the PNG file
|
|
File file = new File("uc.png");
|
|
BufferedImage image = ImageIO.read(file);
|
|
|
|
// Get image dimensions
|
|
int width = image.getWidth();
|
|
int height = image.getHeight();
|
|
|
|
// Iterate over each pixel
|
|
for (int y = 0; y < height; y++) {
|
|
for (int x = 0; x < width; x++) {
|
|
// Get the RGBA value of the pixel
|
|
int pixel = image.getRGB(x, y);
|
|
|
|
// Extract individual color components
|
|
int alpha = (pixel >> 24) & 0xFF;
|
|
int red = (pixel >> 16) & 0xFF;
|
|
int green = (pixel >> 8) & 0xFF;
|
|
int blue = pixel & 0xFF;
|
|
|
|
// Print RGBA values
|
|
/*System.out.println("Pixel at (" + x + ", " + y + "):");
|
|
System.out.println(" Alpha: " + alpha);
|
|
System.out.println(" Red: " + red);
|
|
System.out.println(" Green: " + green);
|
|
System.out.println(" Blue: " + blue);*/
|
|
System.out.println(Integer.toHexString(pixel));
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|