From edf73846318b380ea07371844e5c70b027957ae3 Mon Sep 17 00:00:00 2001 From: darkress <30271678+DarkressX@users.noreply.github.com> Date: Fri, 9 Jun 2023 01:48:49 +0200 Subject: [PATCH] Init --- .gitignore | 1 + de/darkress/pixelfood/Main.java | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 de/darkress/pixelfood/Main.java diff --git a/.gitignore b/.gitignore index f98d166..f26f735 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ replay_pid* #IntelliJ .idea +*.iml #Custom out diff --git a/de/darkress/pixelfood/Main.java b/de/darkress/pixelfood/Main.java new file mode 100644 index 0000000..bab5e36 --- /dev/null +++ b/de/darkress/pixelfood/Main.java @@ -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(); + } + } +}