01: /*
02: * $RCSfile: GIFCodec.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:36 $
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.FileInputStream;
18: import java.io.InputStream;
19: import java.io.IOException;
20: import java.io.OutputStream;
21: import com.sun.media.jai.codec.ImageCodec;
22: import com.sun.media.jai.codec.ImageDecoder;
23: import com.sun.media.jai.codec.ImageDecodeParam;
24: import com.sun.media.jai.codec.ImageEncoder;
25: import com.sun.media.jai.codec.ImageEncodeParam;
26: import com.sun.media.jai.codec.SeekableStream;
27:
28: // import com.sun.media.jai.codec.GIFEncodeParam;
29:
30: /**
31: * @since EA3
32: */
33: public final class GIFCodec extends ImageCodec {
34:
35: public GIFCodec() {
36: }
37:
38: public String getFormatName() {
39: return "gif";
40: }
41:
42: public Class getEncodeParamClass() {
43: return Object.class;
44: }
45:
46: public Class getDecodeParamClass() {
47: return Object.class;
48: }
49:
50: public boolean canEncodeImage(RenderedImage im,
51: ImageEncodeParam param) {
52: return false;
53: }
54:
55: protected ImageEncoder createImageEncoder(OutputStream dst,
56: ImageEncodeParam param) {
57: /*
58: GIFEncodeParam p = null;
59: if (param != null) {
60: p = (GIFEncodeParam)param;
61: }
62:
63: return new GIFImageEncoder(dst, p);
64: */
65:
66: return null;
67: }
68:
69: protected ImageDecoder createImageDecoder(InputStream src,
70: ImageDecodeParam param) {
71: return new GIFImageDecoder(src, param);
72: }
73:
74: protected ImageDecoder createImageDecoder(File src,
75: ImageDecodeParam param) throws IOException {
76: return new GIFImageDecoder(new FileInputStream(src), null);
77: }
78:
79: protected ImageDecoder createImageDecoder(SeekableStream src,
80: ImageDecodeParam param) {
81: return new GIFImageDecoder(src, param);
82: }
83:
84: public int getNumHeaderBytes() {
85: return 4;
86: }
87:
88: public boolean isFormatRecognized(byte[] header) {
89: return ((header[0] == 'G') && (header[1] == 'I')
90: && (header[2] == 'F') && (header[3] == '8'));
91: }
92: }
|