2 * Imagesqueeze - Image codec optimized for photos.
3 * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
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.
10 package eu.svjatoslav.imagesqueeze.sampleApplication;
13 import java.io.IOException;
14 import java.io.InputStream;
18 public static void main(final String[] args) {
22 final String image = "colorful photo";
23 final String sourceDirectory = "/eu/svjatoslav/imagesqueeze/sampleApplication/data/";
25 // create visible frame
26 // load image into frame
27 final InputStream inputStream = Main.class
28 .getResourceAsStream(sourceDirectory + image + ".png");
30 final ImageFrame frame = new ImageFrame("Original image");
31 frame.getImagePanel().loadImage(inputStream, false);
32 frame.setVisible(true);
34 // encode image into file
35 frame.getImagePanel().saveImage(new File(image + ".ImgSqz"));
37 // create second frame for decoded image
38 final ImageFrame frame2 = new ImageFrame("Encoded -> Decoded");
41 frame2.getImagePanel().loadImage(new File(image + ".ImgSqz"), true);
42 frame2.setVisible(true);
44 } catch (final IOException exception) {
45 System.out.println("Error while loading an image: " + exception);