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/Aufgabe.java | 13 ++ src/aufgaben/b20160411/Aufgabe1.java | 62 ++++++++ src/aufgaben/b20160411/Aufgabe2.java | 56 +++++++ src/aufgaben/b20160411/Aufgabe3.java | 58 +++++++ src/aufgaben/b20160411/Aufgabe4.java | 56 +++++++ src/aufgaben/b20160411/Aufgabe5.java | 56 +++++++ src/aufgaben/b20160413/Aufgabe4.java | 71 +++++++++ src/aufgaben/b20160413/Aufgabe6.java | 105 +++++++++++++ src/aufgaben/b20160413/Image.java | 68 +++++++++ src/aufgaben/b20160413/Zusatz1.java | 84 +++++++++++ src/aufgaben/b20160420/Aufgabe2.java | 76 ++++++++++ src/aufgaben/b20160425/Aufgabe1.java | 73 +++++++++ src/aufgaben/b20160425/Aufgabe2.java | 82 ++++++++++ src/aufgaben/b20160425/Aufgabe3.java | 121 +++++++++++++++ src/aufgaben/b20160604/Aufgabe1.java | 109 ++++++++++++++ src/aufgaben/b20160604/Aufgabe2.java | 63 ++++++++ src/aufgaben/b20160604/Aufgabe3.java | 67 +++++++++ src/aufgaben/b20160604/Aufgabe4.java | 79 ++++++++++ src/aufgaben/bildverarbeitung/Aufgabe1.java | 72 +++++++++ src/aufgaben/bildverarbeitung/Aufgabe3.java | 59 ++++++++ src/aufgaben/blatt1/Aufgabe1.java | 58 +++++++ src/aufgaben/blatt1/Aufgabe2a.java | 58 +++++++ src/aufgaben/blatt1/Aufgabe2b40.java | 97 ++++++++++++ src/aufgaben/blatt1/Aufgabe2bEPIC.java | 97 ++++++++++++ src/aufgaben/blatt1/Aufgabe2c40.java | 58 +++++++ src/aufgaben/blatt1/Aufgabe2c40UTF8.java | 58 +++++++ src/aufgaben/blatt1/Aufgabe2cEPIC.java | 58 +++++++ src/aufgaben/blatt1/Aufgabe2cEPICUTF8.java | 58 +++++++ src/aufgaben/blatt2/Aufgabe1.java | 64 ++++++++ src/aufgaben/blatt2/Objekt.java | 65 ++++++++ src/aufgaben/imageio/Aufgabe1.java | 193 ++++++++++++++++++++++++ src/aufgaben/imageio/ImageType.java | 8 + src/aufgaben/imageio/Komprimierung1.java | 225 ++++++++++++++++++++++++++++ 33 files changed, 2527 insertions(+) create mode 100755 src/aufgaben/Aufgabe.java create mode 100755 src/aufgaben/b20160411/Aufgabe1.java create mode 100755 src/aufgaben/b20160411/Aufgabe2.java create mode 100755 src/aufgaben/b20160411/Aufgabe3.java create mode 100755 src/aufgaben/b20160411/Aufgabe4.java create mode 100755 src/aufgaben/b20160411/Aufgabe5.java 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 create mode 100755 src/aufgaben/b20160420/Aufgabe2.java create mode 100755 src/aufgaben/b20160425/Aufgabe1.java create mode 100755 src/aufgaben/b20160425/Aufgabe2.java create mode 100755 src/aufgaben/b20160425/Aufgabe3.java create mode 100755 src/aufgaben/b20160604/Aufgabe1.java create mode 100755 src/aufgaben/b20160604/Aufgabe2.java create mode 100755 src/aufgaben/b20160604/Aufgabe3.java create mode 100755 src/aufgaben/b20160604/Aufgabe4.java create mode 100755 src/aufgaben/bildverarbeitung/Aufgabe1.java create mode 100755 src/aufgaben/bildverarbeitung/Aufgabe3.java create mode 100755 src/aufgaben/blatt1/Aufgabe1.java create mode 100755 src/aufgaben/blatt1/Aufgabe2a.java create mode 100755 src/aufgaben/blatt1/Aufgabe2b40.java create mode 100755 src/aufgaben/blatt1/Aufgabe2bEPIC.java create mode 100755 src/aufgaben/blatt1/Aufgabe2c40.java create mode 100755 src/aufgaben/blatt1/Aufgabe2c40UTF8.java create mode 100755 src/aufgaben/blatt1/Aufgabe2cEPIC.java create mode 100755 src/aufgaben/blatt1/Aufgabe2cEPICUTF8.java create mode 100755 src/aufgaben/blatt2/Aufgabe1.java create mode 100755 src/aufgaben/blatt2/Objekt.java create mode 100755 src/aufgaben/imageio/Aufgabe1.java create mode 100755 src/aufgaben/imageio/ImageType.java create mode 100755 src/aufgaben/imageio/Komprimierung1.java (limited to 'src/aufgaben') diff --git a/src/aufgaben/Aufgabe.java b/src/aufgaben/Aufgabe.java new file mode 100755 index 0000000..174ee26 --- /dev/null +++ b/src/aufgaben/Aufgabe.java @@ -0,0 +1,13 @@ +package aufgaben; + +import java.awt.Frame; + +public abstract class Aufgabe extends Frame { + + public abstract boolean done(); + + public abstract void init(); + + public abstract String getName(); + +} diff --git a/src/aufgaben/b20160411/Aufgabe1.java b/src/aufgaben/b20160411/Aufgabe1.java new file mode 100755 index 0000000..ebd4cb7 --- /dev/null +++ b/src/aufgaben/b20160411/Aufgabe1.java @@ -0,0 +1,62 @@ +package aufgaben.b20160411; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import misc.Utils; +import aufgaben.Aufgabe; + +public class Aufgabe1 extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done; + private String name; + + public Aufgabe1() { + name = "RGB Farbraum - Aufgabe 1"; + done = false; + this.setSize(width, height); + this.setTitle("Blatt 1 - Aufgabe 1"); + } + + @Override + public boolean done() { + return false; + } + + public void paint(Graphics g) { + int r = 0, b = 0; + for(int x = 50; x<110; x+=10) { + for(int y = 50; y<110; y+=10) { + b += 42; + g.setColor(new Color(0,0,0)); + g.drawRect(x, y, 10, 10); + g.setColor(new Color(r, 0, b)); + g.fillRect(x, y, 10, 10); + } + r += 42; + b = 0; + } + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + +} diff --git a/src/aufgaben/b20160411/Aufgabe2.java b/src/aufgaben/b20160411/Aufgabe2.java new file mode 100755 index 0000000..deb21c2 --- /dev/null +++ b/src/aufgaben/b20160411/Aufgabe2.java @@ -0,0 +1,56 @@ +package aufgaben.b20160411; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import misc.Utils; +import aufgaben.Aufgabe; + +public class Aufgabe2 extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done; + private String name; + + public Aufgabe2() { + name = "RGB Farbraum - Aufgabe 2"; + done = false; + this.setSize(width, height); + this.setTitle(name); + } + + @Override + public boolean done() { + return false; + } + + public void paint(Graphics g) { + for(int i = 0; i<255; i++) { + g.setColor(new Color(255-i, 0, i)); + g.drawLine(100+i, 100, 100+i, 355); + } + g.setColor(new Color(0,0,0)); + g.drawRect(100, 100, 255, 255); + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + +} diff --git a/src/aufgaben/b20160411/Aufgabe3.java b/src/aufgaben/b20160411/Aufgabe3.java new file mode 100755 index 0000000..c6e9510 --- /dev/null +++ b/src/aufgaben/b20160411/Aufgabe3.java @@ -0,0 +1,58 @@ +package aufgaben.b20160411; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import misc.Utils; +import aufgaben.Aufgabe; + +public class Aufgabe3 extends Aufgabe { + + private final int width = 1000, height = 500; + private boolean done; + private String name; + + public Aufgabe3() { + name = "RGB Farbraum - Aufgabe 3"; + done = false; + this.setSize(width, height); + this.setTitle(name); + } + + @Override + public boolean done() { + return false; + } + + public void paint(Graphics g) { + for(int i = 0; i<255; i++) { + g.setColor(new Color(255-i, 0, i)); + g.drawLine(100+i, 100, 100+i, 355); + } + for(int i = 0; i<255; i++) { + g.setColor(new Color(0, i, 255-i)); + g.drawLine(355+i, 100, 355+i, 355); + } + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + +} diff --git a/src/aufgaben/b20160411/Aufgabe4.java b/src/aufgaben/b20160411/Aufgabe4.java new file mode 100755 index 0000000..7f3250e --- /dev/null +++ b/src/aufgaben/b20160411/Aufgabe4.java @@ -0,0 +1,56 @@ +package aufgaben.b20160411; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import misc.Utils; +import aufgaben.Aufgabe; + +public class Aufgabe4 extends Aufgabe { + + private final int width = 1000, height = 1000; + private boolean done; + private String name; + + public Aufgabe4() { + name = "RGB Farbraum - Aufgabe 4"; + done = false; + this.setSize(width, height); + this.setTitle(name); + } + + @Override + public boolean done() { + return false; + } + + public void paint(Graphics g) { + for(int i = 0; i<255; i++) { + g.setColor(new Color(255-i, 0, i)); + g.drawLine(100+i, 100, 100+i, 255); + } + g.setColor(new Color(0,0,0)); + g.drawRect(100, 100, 255, 255); + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + +} diff --git a/src/aufgaben/b20160411/Aufgabe5.java b/src/aufgaben/b20160411/Aufgabe5.java new file mode 100755 index 0000000..124feed --- /dev/null +++ b/src/aufgaben/b20160411/Aufgabe5.java @@ -0,0 +1,56 @@ +package aufgaben.b20160411; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import misc.Utils; +import aufgaben.Aufgabe; + +public class Aufgabe5 extends Aufgabe { + + private final int width = 1000, height = 1000; + private boolean done; + private String name; + + public Aufgabe5() { + name = "RGB Farbraum - Aufgabe 5"; + done = false; + this.setSize(width, height); + this.setTitle(name); + } + + @Override + public boolean done() { + return false; + } + + public void paint(Graphics g) { + for(int i = 0; i<255; i++) { + g.setColor(new Color(255-i, 0, i)); + g.drawLine(100+i, 100, 100+i, 255); + } + g.setColor(new Color(0,0,0)); + g.drawRect(100, 100, 255, 255); + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + +} 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]); + } + } + +} diff --git a/src/aufgaben/b20160420/Aufgabe2.java b/src/aufgaben/b20160420/Aufgabe2.java new file mode 100755 index 0000000..3199885 --- /dev/null +++ b/src/aufgaben/b20160420/Aufgabe2.java @@ -0,0 +1,76 @@ +package aufgaben.b20160420; + +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 Aufgabe2 extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done = false; + private String name; + private BufferedImage image; + + public Aufgabe2() { + name = "Komische Methoden"; + 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, 50, 50, 500, 300, this); + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + try { + image = ImageIO.read(new File("title.png")); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private int getGrayValueImg(int x, int y) { + if(image == null) return -1; + Color c = new Color(image.getRGB(x, y)); + if(c.getRed() == c.getGreen() && c.getRed() == c.getBlue()) + return c.getRed(); + return -1; + } + + private void setGrayValueImgProc(int x, int y, int gray) { + if(image == null) + System.out.println("err"); + image.setRGB(x, y, new Color(gray, gray, gray).getRGB()); + } + +} diff --git a/src/aufgaben/b20160425/Aufgabe1.java b/src/aufgaben/b20160425/Aufgabe1.java new file mode 100755 index 0000000..9f90600 --- /dev/null +++ b/src/aufgaben/b20160425/Aufgabe1.java @@ -0,0 +1,73 @@ +package aufgaben.b20160425; + +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 Aufgabe1 extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done = false; + private String name; + private BufferedImage image, todraw; + private Color[][] pixels; + + public Aufgabe1() { + name = "Spiegelung"; + 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(todraw, 0, 100, 500, 300, this); + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + System.out.println("test"); + pixels = new Color[width][height]; + try { + image = ImageIO.read(new File("kraehne2.jpg")); + todraw = ImageIO.read(new File("kraehne2.jpg")); + for(int x = image.getWidth()-1, width = image.getWidth(); x>0; x--) { + for(int y = 0, height = image.getHeight(); y= 0 && absoluteX < image.getWidth() && absoluteY >= 0 && absoluteY < image.getHeight()) { + color = new Color(image.getRGB(absoluteX, absoluteY)); + colori[0] += color.getRed(); + colori[1] += color.getGreen(); + colori[2] += color.getBlue(); + c++; + } + } + } + return new Color(colori[0]/c, colori[1]/c, colori[2]/c); + } + +} diff --git a/src/aufgaben/b20160604/Aufgabe1.java b/src/aufgaben/b20160604/Aufgabe1.java new file mode 100755 index 0000000..9574334 --- /dev/null +++ b/src/aufgaben/b20160604/Aufgabe1.java @@ -0,0 +1,109 @@ +package aufgaben.b20160604; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import function.Display; +import function.Grade1; +import function.Grade2; +import function.Sin; +import function.SquareRoot; +import misc.Utils; +import aufgaben.Aufgabe; +import aufgaben.blatt2.Objekt; + +public class Aufgabe1 extends Aufgabe implements Runnable { + + private final int width = 500, height = 500; + private volatile boolean done; + private String name; + private Display wasser, boot, segel; + private Display[] regenbogen; + + public Aufgabe1() { + name = "BV 2 - Aufgabe 1"; + done = false; + 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) { + wasser.draw(g); + boot.draw(g); + g.drawLine(250, 385, 350, 385); + g.drawLine(350, 385, 350, 415); + g.drawLine(300, 385, 300, 300); + segel.draw(g); + g.drawLine(300, 385, 330, 370); + g.drawOval(450, 0, 100, 100); + g.drawLine(400, 50, 450, 50); + g.drawLine(400, 60, 450, 60); + //ziel1 bei 475, 75 + g.drawLine(419, 100, 457, 75); + g.drawLine(426, 110, 464, 85); + for(int i = 0; i= 0 && dir < 90) { + x += change * v; + y -= Math.tan(Math.toRadians(dir)) * change * v; + } else if(dir >= 90 && dir < 180) { + x -= Math.tan(Math.toRadians(dir-90)) * change * v; + y -= change * v; + } else if(dir >= 180 && dir < 270) { + x -= change * v; + y += Math.tan(Math.toRadians(dir-180)) * change * v; + } else if(dir >= 270 && dir < 360) { + x += Math.tan(Math.toRadians(dir-270)) * change * v; + y += change * v; + } else { + System.out.println("Invalid angle! (float, 0<=angle<=360)"); + } + System.out.println("X = " + x + ", Y = " + y + ", fps = " + delta/1e9); + } + + public int getX() { + return Math.round(x); + } + + public int getY() { + return Math.round(y); + } + + public long getDelta() { + long old = time; + time = System.nanoTime(); + return time-old; + } +} diff --git a/src/aufgaben/imageio/Aufgabe1.java b/src/aufgaben/imageio/Aufgabe1.java new file mode 100755 index 0000000..6394f80 --- /dev/null +++ b/src/aufgaben/imageio/Aufgabe1.java @@ -0,0 +1,193 @@ +package aufgaben.imageio; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import aufgaben.Aufgabe; +import misc.Utils; + +public class Aufgabe1 extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done = false; + private String name; + private JPanel panel; + private JTextField inPath, outPath; + private JButton readButton, writeButton; + private BufferedImage bild; + + public Aufgabe1() { + name = "Lesen Speichern"; + 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() { + inPath = new JTextField(); + inPath.setBounds(50, 50, 200, 20); + outPath = new JTextField(); + outPath.setBounds(50, 80, 200, 20); + readButton = new JButton("Lesen"); + readButton.setBounds(260, 50, 100, 20); + readButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + bild = readImage(new File(inPath.getText())); + /* + try { + bild = ImageIO.read(new File("title.png")); + } catch (IOException e) { + e.printStackTrace(); + } + */ + panel.repaint(); + } + }); + writeButton = new JButton("Schreiben"); + writeButton.setBounds(260, 80, 100, 20); + writeButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + writeImage(new File(outPath.getText()), bild); + } + }); + panel = new JPanel() { + public void paint(Graphics g) { + if(bild != null) + g.drawImage(bild, 0, 0, 500, 390, this); + } + }; + panel.setBounds(0, 110, 500, 390); + this.add(inPath); + this.add(outPath); + this.add(readButton); + this.add(writeButton); + this.add(panel); + this.repaint(); + } + + private BufferedImage getGreyImage(BufferedImage i) { + BufferedImage image = new BufferedImage(i.getWidth(), i.getHeight(), i.getType()); + for(int x = 0, width = i.getWidth(); x> 24) & 0xFF), + (byte) ((a >> 16) & 0xFF), + (byte) ((a >> 8) & 0xFF), + (byte) (a & 0xFF) + }; + } + +} diff --git a/src/aufgaben/imageio/ImageType.java b/src/aufgaben/imageio/ImageType.java new file mode 100755 index 0000000..cfecabe --- /dev/null +++ b/src/aufgaben/imageio/ImageType.java @@ -0,0 +1,8 @@ +package aufgaben.imageio; + +public class ImageType { + + public static final byte RAW = 0x00; + public static final byte COMPRESSED = 0x01; + +} diff --git a/src/aufgaben/imageio/Komprimierung1.java b/src/aufgaben/imageio/Komprimierung1.java new file mode 100755 index 0000000..2265560 --- /dev/null +++ b/src/aufgaben/imageio/Komprimierung1.java @@ -0,0 +1,225 @@ +package aufgaben.imageio; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.JTextField; +import javax.swing.SpinnerNumberModel; + +import aufgaben.Aufgabe; +import misc.CompressedImage; +import misc.Stapel; +import misc.Utils; + +public class Komprimierung1 extends Aufgabe { + + private final int width = 500, height = 500; + private boolean done = false; + private String name; + private JPanel panel; + private JTextField inPath, outPath; + private JButton readButton, writeButton, compButton; + private JSpinner spinnerWidth, spinnerHeight, spinnerColors; + private BufferedImage bild, towrite; + private CompressedImage compressed; + private ArrayList compData; + + public Komprimierung1() { + name = "Komprimierung 1"; + 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() { + inPath = new JTextField(); + inPath.setBounds(20, 40, 150, 20); + outPath = new JTextField(); + outPath.setBounds(20, 70, 150, 20); + readButton = new JButton("Lesen"); + readButton.setBounds(180, 40, 100, 20); + readButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + //bild = readImage(new File(inPath.getText())); + try { + bild = ImageIO.read(new File("title.png")); + } catch (IOException e) { + e.printStackTrace(); + } + + towrite = new BufferedImage(bild.getWidth(), bild.getHeight(), bild.getType()); + for(int x = 0, width = towrite.getWidth(); x