offset
This commit is contained in:
3
META-INF/MANIFEST.MF
Normal file
3
META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: de.darkress.pixelfood.Main
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ class Main
|
|||||||
return null;
|
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<>();
|
ArrayList<String> pixelArray = new ArrayList<>();
|
||||||
|
|
||||||
int width = image.getWidth();
|
int width = image.getWidth();
|
||||||
@@ -39,7 +39,7 @@ class Main
|
|||||||
int green = (pixel >> 8) & 0xFF;
|
int green = (pixel >> 8) & 0xFF;
|
||||||
int blue = pixel & 0xFF;
|
int blue = pixel & 0xFF;
|
||||||
String rgbValue = String.format("%06X", (pixel & 0xFFFFFF));
|
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)
|
if(alpha != 0)
|
||||||
{
|
{
|
||||||
pixelArray.add(messageParameters);
|
pixelArray.add(messageParameters);
|
||||||
@@ -56,6 +56,8 @@ class Main
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final int PORT = 1234;
|
final int PORT = 1234;
|
||||||
final String HOSTNAME = "localhost";
|
final String HOSTNAME = "localhost";
|
||||||
|
final int xOffset = 0;
|
||||||
|
final int yOffset = 0;
|
||||||
InetAddress serverAddress = null;
|
InetAddress serverAddress = null;
|
||||||
try {
|
try {
|
||||||
serverAddress = InetAddress.getByName(HOSTNAME);
|
serverAddress = InetAddress.getByName(HOSTNAME);
|
||||||
@@ -65,7 +67,7 @@ class Main
|
|||||||
|
|
||||||
// Read the PNG file
|
// Read the PNG file
|
||||||
BufferedImage image = processImage("girl.png");
|
BufferedImage image = processImage("girl.png");
|
||||||
ArrayList<String> pixelArray = prepareArray(image);
|
ArrayList<String> pixelArray = prepareArray(image, xOffset, yOffset);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DatagramSocket socket = new DatagramSocket();
|
DatagramSocket socket = new DatagramSocket();
|
||||||
|
|||||||
Reference in New Issue
Block a user