This commit is contained in:
Darkress
2023-06-09 05:05:01 +02:00
parent ff7ace05c6
commit be0ad9e905
2 changed files with 8 additions and 3 deletions

3
META-INF/MANIFEST.MF Normal file
View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: de.darkress.pixelfood.Main

View File

@@ -21,7 +21,7 @@ class Main
return null;
}
private static ArrayList<String> prepareArray(BufferedImage image) {
private static ArrayList<String> prepareArray(BufferedImage image, int xOffset, int yOffset) {
ArrayList<String> pixelArray = new ArrayList<>();
int width = image.getWidth();
@@ -39,7 +39,7 @@ class Main
int green = (pixel >> 8) & 0xFF;
int blue = pixel & 0xFF;
String rgbValue = String.format("%06X", (pixel & 0xFFFFFF));
String messageParameters = String.format("PX %s %s %s\n", x, y, rgbValue);
String messageParameters = String.format("PX %s %s %s\n", x+xOffset, y+yOffset, rgbValue);
if(alpha != 0)
{
pixelArray.add(messageParameters);
@@ -56,6 +56,8 @@ class Main
public static void main(String[] args) {
final int PORT = 1234;
final String HOSTNAME = "localhost";
final int xOffset = 0;
final int yOffset = 0;
InetAddress serverAddress = null;
try {
serverAddress = InetAddress.getByName(HOSTNAME);
@@ -65,7 +67,7 @@ class Main
// Read the PNG file
BufferedImage image = processImage("girl.png");
ArrayList<String> pixelArray = prepareArray(image);
ArrayList<String> pixelArray = prepareArray(image, xOffset, yOffset);
try {
DatagramSocket socket = new DatagramSocket();