Skip to content

Commit

Permalink
Merge pull request #29 from NoobieBubie1/main
Browse files Browse the repository at this point in the history
FINALLE !!!! DIE HOFFNUNG STIRBT ZU LETZT 🤩
  • Loading branch information
cramosk authored Oct 27, 2023
2 parents 3585d1d + 019a577 commit 8ddbd99
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
24 changes: 9 additions & 15 deletions Teams/red_titans/Dockerfile
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"]

52 changes: 52 additions & 0 deletions Teams/red_titans/src/Inception.java
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();
}
}
}
Binary file added Teams/red_titans/src/inception.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Teams/red_titans/src/simple_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ def run():


if __name__ == "__main__":
#clean(0,1000,0,1000)
clean(0,1000,0,1000)
run()
s.close()

0 comments on commit 8ddbd99

Please sign in to comment.