-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from NoobieBubie1/main
FINALLE !!!! DIE HOFFNUNG STIRBT ZU LETZT 🤩
- Loading branch information
Showing
4 changed files
with
62 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
FROM subfuzion/netcat | ||
FROM python:3.12 | ||
FROM eclipse-temurin:17-jdk-jammy as build | ||
|
||
ENV X=645 | ||
ENV Y=725 | ||
ENV COLOR=e07224 | ||
# Any working directory can be chosen as per choice like '/' or '/home' etc | ||
# i have chosen /usr/app/src | ||
WORKDIR /usr/app/ | ||
#ENTRYPOINT sh -c "echo -en 'PX ${X} ${Y} ${COLOR}\n' | nc -q1 localhost 1234" | ||
RUN python3 -m venv .venv/ | ||
RUN . .venv/bin/activate && pip install --upgrade Pillow | ||
COPY src/Inception.java /src/ | ||
COPY src/inception.png /src/ | ||
RUN javac /src/Inception.java && ls -al /src | ||
|
||
COPY src/ src/ | ||
FROM eclipse-temurin:17-jdk-jammy | ||
|
||
COPY --from=build src/*.class /app/ | ||
|
||
ENTRYPOINT cd app && java Inception | ||
|
||
#CMD [ "python", "./Challenge1.py"] | ||
#CMD [ "/usr/app/.venv/bin/python3", "/usr/app/src/RedBackground.py"] | ||
CMD [ "/usr/app/.venv/bin/python3", "/usr/app/src/simple_client.py"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import java.awt.image.BufferedImage; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.io.OutputStreamWriter; | ||
import java.io.Writer; | ||
import java.net.Socket; | ||
import javax.imageio.ImageIO; | ||
|
||
public class Inception { | ||
static String serverHost = "127.0.0.0"; | ||
static int serverPort = 1234; | ||
public static void main(String[] args) throws IOException { | ||
BufferedImage image = ImageIO.read( | ||
new File("/src/inception.png")); | ||
Socket socket = new Socket(serverHost,serverPort); | ||
OutputStream outputStream = socket.getOutputStream(); | ||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream)); | ||
//Thread für den fall das man noch einen parralel laufen lassen will um noch Schneller das Bild zu zeichnen | ||
// --> man muss das Bild davor Unterteilen damit die beiden Threads unabängig von einander Arbeiten | ||
Thread t1 = new Thread(() -> bildBuilder(image,socket,writer)); | ||
t1.start(); | ||
} | ||
|
||
public static void bildBuilder(BufferedImage image, Socket socket, Writer writer){ | ||
try { | ||
int imageWidth = image.getWidth(); | ||
int imageHeight = image.getHeight(); | ||
for( int y = 0; y < imageHeight; y++){ | ||
for (int x = 0; x < imageWidth; x++){ | ||
int pixel = image.getRGB(x, y); | ||
int red = (pixel >> 16) & 0xFF; | ||
int green = (pixel >> 8) & 0xFF; | ||
int blue = pixel & 0xFF; | ||
int color = (red >> 16) + (green << 8) + blue; | ||
|
||
String command = String.format("PX %d %d %06X\n", x, y, color); | ||
writer.write(command); | ||
writer.flush(); | ||
} | ||
} | ||
writer.close(); | ||
socket.close(); | ||
}catch (Exception e){ | ||
System.out.println("Parralel1" + e.getMessage() + e.getCause()); | ||
e.printStackTrace(); | ||
e.getMessage(); | ||
e.getCause(); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,6 @@ def run(): | |
|
||
|
||
if __name__ == "__main__": | ||
#clean(0,1000,0,1000) | ||
clean(0,1000,0,1000) | ||
run() | ||
s.close() |