This commit is contained in:
darkress
2023-06-09 01:48:49 +02:00
parent 5a8b3a89f5
commit edf7384631
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
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();
}
}
}