Source code: joelib/io/types/JPEG.java
1 ///////////////////////////////////////////////////////////////////////////////
2 // Filename: $RCSfile: JPEG.java,v $
3 // Purpose: Reader/Writer for Undefined files.
4 // Language: Java
5 // Compiler: JDK 1.4
6 // Authors: Joerg K. Wegner
7 // Version: $Revision: 1.1 $
8 // $Date: 2003/10/13 13:23:23 $
9 // $Author: wegner $
10 //
11 // Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation version 2 of the License.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 ///////////////////////////////////////////////////////////////////////////////
22 package joelib.io.types;
23
24 import joelib.io.SimpleImageWriter;
25
26 import java.awt.Image;
27
28 import java.io.IOException;
29 import java.io.OutputStream;
30
31 import org.apache.log4j.Category;
32
33 import com.obrador.JpegEncoder;
34
35
36 /*==========================================================================*
37 * CLASS DECLARATION
38 *==========================================================================*/
39
40 /**
41 * Atom representation.
42 */
43 public class JPEG extends SimpleImageWriter
44 {
45 //~ Static fields/initializers /////////////////////////////////////////////
46
47 /*-------------------------------------------------------------------------*
48 * private static member variables
49 *-------------------------------------------------------------------------*/
50
51 /**
52 * Obtain a suitable logger.
53 */
54 private static Category logger = Category.getInstance(
55 "joelib.io.types.JPEG");
56 private static final String description = new String("JPEG image");
57 private static final String[] extensions = new String[]{"jpg", "jpeg"};
58 private static final int JPEG_QUALITY_IN_PERCENT = 100;
59
60 //~ Methods ////////////////////////////////////////////////////////////////
61
62 public String outputDescription()
63 {
64 return description;
65 }
66
67 public String[] outputFileExtensions()
68 {
69 return extensions;
70 }
71
72 public boolean writeImage(Image image, OutputStream os)
73 throws IOException
74 {
75 JpegEncoder pc = new JpegEncoder(image, JPEG_QUALITY_IN_PERCENT, os);
76 pc.Compress();
77
78 return (true);
79 }
80 }
81 ///////////////////////////////////////////////////////////////////////////////
82 // END OF FILE.
83 ///////////////////////////////////////////////////////////////////////////////