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/imageio/Komprimierung1.java | 225 +++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100755 src/aufgaben/imageio/Komprimierung1.java (limited to 'src/aufgaben/imageio/Komprimierung1.java') 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