KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > image > codec > jpeg > JPEGImageDecoder


1 /*
2  * @(#)JPEGImageDecoder.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 /**********************************************************************
9  **********************************************************************
10  **********************************************************************
11  *** COPYRIGHT (c) 1997-1998 Eastman Kodak Company. ***
12  *** As an unpublished work pursuant to Title 17 of the United ***
13  *** States Code. All rights reserved. ***
14  **********************************************************************
15  **********************************************************************
16  **********************************************************************/

17
18 package com.sun.image.codec.jpeg;
19
20
21 /**
22  * JPEGImageDecoder Interface
23  *
24  * JPEGImageDecoder decompresses an JPEG InputStream into a Raster or
25  * a BufferedImage depending upon the method invoked. Decoding the
26  * JPEG input stream is controlled by the parameters in the
27  * JPEGDecodeParam object. If no JPEGDecodeParam object has been
28  * specified then one is created to contain information about a
29  * decompressed JPEG stream.<P>
30  *
31  * The JPEGDecodeParam object is updated with information from the
32  * file header during decompression. If the input stream contains
33  * tables only information (no image data), the JPEGDecodeParam object
34  * will be updated and NULL returned for the output image. If the
35  * input stream contains only image data, the parameters and tables in
36  * the current JPEGDecodeParam object will be used to decode in
37  * decoding the JPEG stream. If no tables are set in the
38  * JPEGDecodeParam object, an exception will be thrown.<P>
39  *
40  * ColorSpace comments: First off JPEG by specification is color
41  * blind! That said, some color space conversion is done in the name
42  * of better compression ratios. If a BufferedImage is requested
43  * common color conversions will be applied. Some updates to the
44  * standard color space designations have been made to allow this
45  * decoder to handle alpha channels. See the JPEGDecodeParam
46  * description for more details on additional color space
47  * designations ( @see JPEGDecodeParam ).<P>
48  *
49  * This decoder can process interchange, abbreviated and progressive
50  * jpeg streams. However, progressive jpeg streams are treated as
51  * interchange streams. They return once with the entire image in the
52  * image buffer.
53  */

54
55 import java.io.InputStream JavaDoc;
56 import java.io.IOException JavaDoc;
57 import java.awt.Point JavaDoc;
58 import java.awt.color.ColorSpace JavaDoc;
59 import java.awt.image.BufferedImage JavaDoc;
60 import java.awt.image.ColorModel JavaDoc;
61 import java.awt.image.DirectColorModel JavaDoc;
62 import java.awt.image.DataBuffer JavaDoc;
63 import java.awt.image.DataBufferByte JavaDoc;
64 import java.awt.image.DataBufferInt JavaDoc;
65 import java.awt.image.Raster JavaDoc;
66 import java.awt.image.SampleModel JavaDoc;
67 import java.awt.image.WritableRaster JavaDoc;
68
69 /**
70  * This interface describes a JPEG data stream decoder. This decoder
71  * takes an InputStream that contains JPEG encoded image data. The
72  * JPEGImageDecoder will decode the JPEG image data according to the
73  * parameters set in a JPEGDecodeParam object. The resulting image
74  * data is returned in either a Raster or a BufferedImage.
75  * <p>
76  * Note that the classes in the com.sun.image.codec.jpeg package are not
77  * part of the core Java APIs. They are a part of Sun's JDK and JRE
78  * distributions. Although other licensees may choose to distribute these
79  * classes, developers cannot depend on their availability in non-Sun
80  * implementations. We expect that equivalent functionality will eventually
81  * be available in a core API or standard extension.
82  * <p>
83  *
84  * @see JPEGCodec
85  * @see JPEGDecodeParam
86  * @see Raster
87  * @see BufferedImage
88  * @version 4 December 1997
89  */

90  
91 public interface JPEGImageDecoder {
92
93     /**
94      * Returns the JPEGDecodeParam object that resulted from the most
95      * recent decoding event.
96      */

97     public JPEGDecodeParam getJPEGDecodeParam();
98
99     /**
100      * Sets the JPEGDecodeParam object used to determine the features
101      * of the decompression performed on the JPEG encoded data. This
102      * is ussually only needed for decoding abbreviated JPEG data
103      * streams.
104      * @param jdp JPEGDecodeParam object
105      */

106     public void setJPEGDecodeParam(JPEGDecodeParam jdp);
107     
108     /**
109      * Get the input stream that decoding will occur from.
110      * @return The stream that the decoder is currently assciated with.
111      */

112     public InputStream JavaDoc getInputStream();
113
114     /**
115      * Decode the JPEG stream that was passed as part of
116      * construction. The JPEG decompression will be performed
117      * according to the current settings of the JPEGDecodeParam
118      * object. For a tables only stream this will return null.
119      * @return Raster containg the image data. Colorspace and other
120      * pertinent information can be obtained from the
121      * JPEGDecodeParam object.
122      * @exception ImageFormatException if irregularities in the JPEG
123      * stream or an unknown condition is encountered.
124      */

125     public Raster JavaDoc decodeAsRaster()
126         throws IOException JavaDoc, ImageFormatException;
127
128     /**
129      * Decodes the current JPEG data stream. The result of decoding
130      * this InputStream is a BufferedImage the ColorModel associated
131      * with this BufferedImage is determined based on the encoded
132      * COLOR_ID of the JPEGDecodeParam object. For a tables only
133      * stream this will return null.
134      * @return BufferedImage containing the image data.
135      * @exception ImageFormatException if irregularities in the JPEG
136      * stream or an unknown condition is encountered.
137      */

138     public BufferedImage JavaDoc decodeAsBufferedImage()
139         throws IOException JavaDoc, ImageFormatException;
140
141 } // end class JPEGImageDecoder
142

143
Popular Tags