Source code: org/ydp/jai/ImageDecoder.java
1 /*
2 * The contents of this file are subject to the JAVA ADVANCED IMAGING
3 * SAMPLE INPUT-OUTPUT CODECS AND WIDGET HANDLING SOURCE CODE License
4 * Version 1.0 (the "License"); You may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 * http://www.sun.com/software/imaging/JAI/index.html
7 *
8 * Software distributed under the License is distributed on an "AS IS"
9 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
10 * the License for the specific language governing rights and limitations
11 * under the License.
12 *
13 * The Original Code is JAVA ADVANCED IMAGING SAMPLE INPUT-OUTPUT CODECS
14 * AND WIDGET HANDLING SOURCE CODE.
15 * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
16 * Portions created by: _______________________________________
17 * are Copyright (C): _______________________________________
18 * All Rights Reserved.
19 * Contributor(s): _______________________________________
20 */
21
22 package org.ydp.jai;
23
24 import java.awt.image.Raster;
25 import java.awt.image.RenderedImage;
26 import java.io.InputStream;
27 import java.io.IOException;
28
29 /**
30 * An interface describing objects that transform an InputStream into a
31 * BufferedImage or Raster.
32 *
33 * <p><b> This interface is not a committed part of the JAI API. It may
34 * be removed or changed in future releases of JAI.</b>
35 */
36 public interface ImageDecoder {
37
38 /**
39 * Returns the current parameters as an instance of the
40 * ImageDecodeParam interface. Concrete implementations of this
41 * interface will return corresponding concrete implementations of
42 * the ImageDecodeParam interface. For example, a JPEGImageDecoder
43 * will return an instance of JPEGDecodeParam.
44 */
45 ImageDecodeParam getParam();
46
47 /**
48 * Sets the current parameters to an instance of the
49 * ImageDecodeParam interface. Concrete implementations
50 * of ImageDecoder may throw a RuntimeException if the
51 * param argument is not an instance of the appropriate
52 * subclass or subinterface. For example, a JPEGImageDecoder
53 * will expect param to be an instance of JPEGDecodeParam.
54 */
55 void setParam(ImageDecodeParam param);
56
57 /** Returns the SeekableStream associated with this ImageDecoder. */
58 SeekableStream getInputStream();
59
60 /** Returns the number of pages present in the current stream. */
61 int getNumPages() throws IOException;
62
63 /**
64 * Returns a Raster that contains the decoded contents of the
65 * SeekableStream associated with this ImageDecoder. Only
66 * the first page of a multi-page image is decoded.
67 */
68 Raster decodeAsRaster() throws IOException;
69
70 /**
71 * Returns a Raster that contains the decoded contents of the
72 * SeekableStream associated with this ImageDecoder.
73 * The given page of a multi-page image is decoded. If
74 * the page does not exist, an IOException will be thrown.
75 * Page numbering begins at zero.
76 *
77 * @param page The page to be decoded.
78 */
79 Raster decodeAsRaster(int page) throws IOException;
80
81 /**
82 * Returns a RenderedImage that contains the decoded contents of the
83 * SeekableStream associated with this ImageDecoder. Only
84 * the first page of a multi-page image is decoded.
85 */
86 RenderedImage decodeAsRenderedImage() throws IOException;
87
88 /**
89 * Returns a RenderedImage that contains the decoded contents of the
90 * SeekableStream associated with this ImageDecoder.
91 * The given page of a multi-page image is decoded. If
92 * the page does not exist, an IOException will be thrown.
93 * Page numbering begins at zero.
94 *
95 * @param page The page to be decoded.
96 */
97 RenderedImage decodeAsRenderedImage(int page) throws IOException;
98 }