KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > image > codec > tiff > TIFFImageDecoder


1 /*
2
3    Copyright 2001,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.ext.awt.image.codec.tiff;
19
20 import java.awt.image.RenderedImage JavaDoc;
21 import java.io.IOException JavaDoc;
22
23 import org.apache.batik.ext.awt.image.codec.ImageDecodeParam;
24 import org.apache.batik.ext.awt.image.codec.ImageDecoderImpl;
25 import org.apache.batik.ext.awt.image.codec.SeekableStream;
26
27 /**
28  * A baseline TIFF reader. The reader has some functionality in addition to
29  * the baseline specifications for Bilevel images, for which the group 3 and
30  * group 4 decompression schemes have been implemented. Support for LZW
31  * decompression has also been added. Support for Horizontal differencing
32  * predictor decoding is also included, when used with LZW compression.
33  * However, this support is limited to data with bitsPerSample value of 8.
34  * When reading in RGB images, support for alpha and extraSamples being
35  * present has been added. Support for reading in images with 16 bit samples
36  * has been added. Support for the SampleFormat tag (signed samples as well
37  * as floating-point samples) has also been added. In all other cases, support
38  * is limited to Baseline specifications.
39  *
40  *
41  */

42 public class TIFFImageDecoder extends ImageDecoderImpl {
43
44     // All the TIFF tags that we care about
45
public static final int TIFF_IMAGE_WIDTH = 256;
46     public static final int TIFF_IMAGE_LENGTH = 257;
47     public static final int TIFF_BITS_PER_SAMPLE = 258;
48     public static final int TIFF_COMPRESSION = 259;
49     public static final int TIFF_PHOTOMETRIC_INTERPRETATION = 262;
50     public static final int TIFF_FILL_ORDER = 266;
51     public static final int TIFF_STRIP_OFFSETS = 273;
52     public static final int TIFF_SAMPLES_PER_PIXEL = 277;
53     public static final int TIFF_ROWS_PER_STRIP = 278;
54     public static final int TIFF_STRIP_BYTE_COUNTS = 279;
55     public static final int TIFF_X_RESOLUTION = 282;
56     public static final int TIFF_Y_RESOLUTION = 283;
57     public static final int TIFF_PLANAR_CONFIGURATION = 284;
58     public static final int TIFF_T4_OPTIONS = 292;
59     public static final int TIFF_T6_OPTIONS = 293;
60     public static final int TIFF_RESOLUTION_UNIT = 296;
61     public static final int TIFF_PREDICTOR = 317;
62     public static final int TIFF_COLORMAP = 320;
63     public static final int TIFF_TILE_WIDTH = 322;
64     public static final int TIFF_TILE_LENGTH = 323;
65     public static final int TIFF_TILE_OFFSETS = 324;
66     public static final int TIFF_TILE_BYTE_COUNTS = 325;
67     public static final int TIFF_EXTRA_SAMPLES = 338;
68     public static final int TIFF_SAMPLE_FORMAT = 339;
69     public static final int TIFF_S_MIN_SAMPLE_VALUE = 340;
70     public static final int TIFF_S_MAX_SAMPLE_VALUE = 341;
71
72     public TIFFImageDecoder(SeekableStream input,
73                             ImageDecodeParam param) {
74         super(input, param);
75     }
76
77     public int getNumPages() throws IOException JavaDoc {
78         return TIFFDirectory.getNumDirectories(input);
79     }
80
81     public RenderedImage JavaDoc decodeAsRenderedImage(int page) throws IOException JavaDoc {
82         if ((page < 0) || (page >= getNumPages())) {
83             throw new IOException JavaDoc("TIFFImageDecoder0");
84         }
85         return new TIFFImage(input, (TIFFDecodeParam)param, page);
86     }
87 }
88
Popular Tags