c6a022c0555c9fd1f8b1d3918db1b8d4e238cb1e
[imagesqueeze.git] / src / main / java / eu / svjatoslav / imagesqueeze / sampleApplication / Main.java
1 /*
2  * Imagesqueeze - Image codec. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public License
6  * or later as published by the Free Software Foundation.
7  */
8
9 package eu.svjatoslav.imagesqueeze.sampleApplication;
10
11 import java.io.File;
12 import java.io.IOException;
13 import java.io.InputStream;
14
15 public class Main {
16
17     public static void main(final String[] args) throws IOException {
18
19         final String image = "colorful photo";
20         final String sourceDirectory = "/eu/svjatoslav/imagesqueeze/sampleApplication/data/";
21
22         // create visible frame
23         // load image into frame
24         final InputStream inputStream = Main.class
25                 .getResourceAsStream(sourceDirectory + image + ".png");
26
27         final ImageFrame frame = new ImageFrame("Original image");
28         frame.getImagePanel().loadImage(inputStream, false);
29         frame.setVisible(true);
30
31         // encode image into file
32         frame.getImagePanel().saveImage(new File(image + ".ImgSqz"));
33
34         // create second frame for decoded image
35         final ImageFrame frame2 = new ImageFrame("Encoded -> Decoded");
36
37         // decode image
38         frame2.getImagePanel().loadImage(new File(image + ".ImgSqz"), true);
39         frame2.setVisible(true);
40
41     }
42
43 }