01: /*
02: * $RCSfile: TIFFCodec.java,v $
03: *
04: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
05: *
06: * Use is subject to license terms.
07: *
08: * $Revision: 1.1 $
09: * $Date: 2005/02/11 04:55:39 $
10: * $State: Exp $
11: */
12:
13: package com.sun.media.jai.codecimpl;
14:
15: import java.awt.image.RenderedImage;
16: import java.io.File;
17: import java.io.InputStream;
18: import java.io.IOException;
19: import java.io.OutputStream;
20: import com.sun.media.jai.codec.ImageCodec;
21: import com.sun.media.jai.codec.ImageDecoder;
22: import com.sun.media.jai.codec.ImageDecodeParam;
23: import com.sun.media.jai.codec.ImageEncoder;
24: import com.sun.media.jai.codec.ImageEncodeParam;
25: import com.sun.media.jai.codec.FileSeekableStream;
26: import com.sun.media.jai.codec.SeekableStream;
27: import com.sun.media.jai.codec.TIFFEncodeParam;
28:
29: /**
30: * @since EA3
31: */
32: public final class TIFFCodec extends ImageCodec {
33:
34: public TIFFCodec() {
35: }
36:
37: public String getFormatName() {
38: return "tiff";
39: }
40:
41: public Class getEncodeParamClass() {
42: return com.sun.media.jai.codec.TIFFEncodeParam.class;
43: }
44:
45: public Class getDecodeParamClass() {
46: return com.sun.media.jai.codec.TIFFDecodeParam.class;
47: }
48:
49: public boolean canEncodeImage(RenderedImage im,
50: ImageEncodeParam param) {
51: return true;
52: }
53:
54: protected ImageEncoder createImageEncoder(OutputStream dst,
55: ImageEncodeParam param) {
56: return new TIFFImageEncoder(dst, param);
57: }
58:
59: protected ImageDecoder createImageDecoder(SeekableStream src,
60: ImageDecodeParam param) {
61: return new TIFFImageDecoder(src, param);
62: }
63:
64: public int getNumHeaderBytes() {
65: return 4;
66: }
67:
68: public boolean isFormatRecognized(byte[] header) {
69: if ((header[0] == 0x49) && (header[1] == 0x49)
70: && (header[2] == 0x2a) && (header[3] == 0x00)) {
71: return true;
72: }
73:
74: if ((header[0] == 0x4d) && (header[1] == 0x4d)
75: && (header[2] == 0x00) && (header[3] == 0x2a)) {
76: return true;
77: }
78:
79: return false;
80: }
81: }
|