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