01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.harmony.x.imageio.plugins.gif;
18:
19: import java.io.IOException;
20: import java.util.Locale;
21:
22: import javax.imageio.ImageReader;
23: import javax.imageio.spi.ImageReaderSpi;
24:
25: import org.apache.harmony.x.imageio.plugins.ImageSignature;
26: import org.apache.harmony.x.imageio.plugins.ImageType;
27: import org.apache.harmony.x.imageio.plugins.PluginUtils;
28:
29: public class GIFImageReaderSpi extends ImageReaderSpi {
30:
31: public GIFImageReaderSpi() {
32: super (PluginUtils.VENDOR_NAME, PluginUtils.DEFAULT_VERSION,
33: ImageType.GIF.getNames(), ImageType.GIF.getSuffixes(),
34: ImageType.GIF.getMimeTypes(), GIFImageReader.class
35: .getName(), STANDARD_INPUT_TYPE, null, false,
36: null, null, null, null, false, null, null, null, null);
37: }
38:
39: @Override
40: public boolean canDecodeInput(final Object source)
41: throws IOException {
42: final byte[] sig = ImageSignature.readSignature(source, 6);
43: return ImageSignature.GIF87a.verify(sig)
44: || ImageSignature.GIF89a.verify(sig);
45: }
46:
47: @Override
48: public ImageReader createReaderInstance(Object extension)
49: throws IOException {
50: return new GIFImageReader(this );
51: }
52:
53: @Override
54: public String getDescription(Locale locale) {
55: return "GIF image decoder"; //$NON-NLS-1$
56: }
57:
58: }
|