From 84e220b332bfffb0f2dcc39b9697a6fd6691d265 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:36:30 +0200 Subject: Initial commit --- src/aufgaben/b20160413/Aufgabe4.java | 71 +++++++++++++++++++++++ src/aufgaben/b20160413/Aufgabe6.java | 105 +++++++++++++++++++++++++++++++++++ src/aufgaben/b20160413/Image.java | 68 +++++++++++++++++++++++ src/aufgaben/b20160413/Zusatz1.java | 84 ++++++++++++++++++++++++++++ 4 files changed, 328 insertions(+) create mode 100755 src/aufgaben/b20160413/Aufgabe4.java create mode 100755 src/aufgaben/b20160413/Aufgabe6.java create mode 100755 src/aufgaben/b20160413/Image.java create mode 100755 src/aufgaben/b20160413/Zusatz1.java (limited to 'src/aufgaben/b20160413') diff --git a/src/aufgaben/b20160413/Aufgabe4.java b/src/aufgaben/b20160413/Aufgabe4.java new file mode 100755 index 0000000..ad720b9 --- /dev/null +++ b/src/aufgaben/b20160413/Aufgabe4.java @@ -0,0 +1,71 @@ +package aufgaben.b20160413; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import aufgaben.Aufgabe; +import misc.Utils; + +public class Aufgabe4 extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done = false; + private String name; + private BufferedImage image; + private Color[][] pixels; + + public Aufgabe4() { + name = "Graustufen"; + this.setSize(width, height); + this.setTitle(name); + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + + @Override + public boolean done() { + return done; + } + + public void paint(Graphics g) { + if(image != null) + g.drawImage(image, 0, 100, 500, 300, this); + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + pixels = new Color[width][height]; + try { + image = ImageIO.read(new File("title.png")); + for(int x = 0, width = image.getWidth(); x arr; + + public Aufgabe6() { + name = "YUV Visualisierung"; + this.setSize(width, height); + this.setTitle(name); + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + this.setLayout(null); + } + + @Override + public boolean done() { + return done; + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + arr = new ArrayList(); + panel = new JPanel() { + public void paint(Graphics g) { + g.clearRect(0, 0, this.getWidth(), this.getHeight()); + for(int x = 0; x= 0.0 && gr >= 0.0 && b >= 0.0 && r <= 1.0 && gr <= 1.0 && b <= 1.0) { + g.setColor(new Color((int)Math.round(r*255), (int)Math.round(gr*255), (int)Math.round(b*255))); + g.fillRect(x, y, 1, 1); + } + } + } + /* + double max = 0.0; + for(int x = 0; xarr.get(y)) + max = arr.get(x); + } + } + System.out.println(max); + */ + g.setColor(Color.BLACK); + g.drawRect(0, 0, 199, 199); + } + }; + panel.setBounds(100, 200, 200, 200); + spinner = new JSpinner(new SpinnerNumberModel(1f, 0f, 1f, 0.01f)); + spinner.setBounds(100, 100, 100, 20); + spinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + panel.repaint(); + } + }); + this.add(panel); + this.add(spinner); + } + +} diff --git a/src/aufgaben/b20160413/Image.java b/src/aufgaben/b20160413/Image.java new file mode 100755 index 0000000..eb3b95f --- /dev/null +++ b/src/aufgaben/b20160413/Image.java @@ -0,0 +1,68 @@ +package aufgaben.b20160413; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import aufgaben.Aufgabe; +import misc.Utils; + +public class Image extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done = false; + private String name; + private BufferedImage image; + + public Image() { + name = "Image"; + this.setSize(width, height); + this.setTitle(name); + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + + @Override + public boolean done() { + return done; + } + + public void paint(Graphics g) { + if(image != null) + g.drawImage(image, 0, 100, 500, 300, this); + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + try { + image = ImageIO.read(new File("title.png")); + Color c = new Color(image.getRGB(400, 150)); + System.out.println("R: " + c.getRed() + ", G: " + c.getGreen() + ", B: " + c.getBlue()); + c = new Color(image.getRGB(410, 150)); + System.out.println("R: " + c.getRed() + ", G: " + c.getGreen() + ", B: " + c.getBlue()); + c = new Color(image.getRGB(420, 150)); + System.out.println("R: " + c.getRed() + ", G: " + c.getGreen() + ", B: " + c.getBlue()); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/aufgaben/b20160413/Zusatz1.java b/src/aufgaben/b20160413/Zusatz1.java new file mode 100755 index 0000000..470a908 --- /dev/null +++ b/src/aufgaben/b20160413/Zusatz1.java @@ -0,0 +1,84 @@ +package aufgaben.b20160413; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import aufgaben.Aufgabe; +import misc.Utils; + +public class Zusatz1 extends Aufgabe { + + private final int width = 110, height = 200; + private boolean done = false; + private String name; + private JSpinner[] spinners; + + public Zusatz1() { + name = "RGB Int Umwandlung"; + this.setSize(width, height); + this.setTitle(name); + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + this.setLayout(null); + } + + @Override + public boolean done() { + return done; + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + spinners = new JSpinner[4]; + spinners[0] = new JSpinner(new SpinnerNumberModel(0, 0, 16777215, 1)); + spinners[0].setBounds(10, 50, 100, 20); + spinners[1] = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + spinners[1].setBounds(10, 80, 100, 20); + spinners[2] = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + spinners[2].setBounds(10, 110, 100, 20); + spinners[3] = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + spinners[3].setBounds(10, 140, 100, 20); + for(int i = 0; i> 8) & 0xFF)); + spinners[3].setValue((int)(((int)spinners[0].getValue() >> 16) & 0xFF)); + } else if(e.getSource().equals(spinners[1])) { + spinners[0].setValue((int)spinners[1].getValue() & 0xFF | ((int)spinners[2].getValue() & 0xFF) << 8 | ((int)spinners[3].getValue() & 0xFF) << 16); + } else if(e.getSource().equals(spinners[2])) { + spinners[0].setValue((int)spinners[1].getValue() & 0xFF | ((int)spinners[2].getValue() & 0xFF) << 8 | ((int)spinners[3].getValue() & 0xFF) << 16); + } else if(e.getSource().equals(spinners[3])) { + spinners[0].setValue((int)spinners[1].getValue() & 0xFF | ((int)spinners[2].getValue() & 0xFF) << 8 | ((int)spinners[3].getValue() & 0xFF) << 16); + } + } + }); + this.add(spinners[i]); + } + } + +} -- cgit v1.2.1