1 7 8 package com.sun.imageio.plugins.gif; 9 10 import java.io.IOException ; 11 import java.util.Locale ; 12 import java.util.Iterator ; 13 import javax.imageio.ImageReader ; 14 import javax.imageio.metadata.IIOMetadataFormat ; 15 import javax.imageio.metadata.IIOMetadataFormatImpl ; 16 import javax.imageio.spi.ImageReaderSpi ; 17 import javax.imageio.stream.ImageInputStream ; 18 19 22 public class GIFImageReaderSpi extends ImageReaderSpi { 23 24 private static final String vendorName = "Sun Microsystems, Inc."; 25 26 private static final String version = "1.0"; 27 28 private static final String [] names = { "gif" }; 29 30 private static final String [] suffixes = { "gif" }; 31 32 private static final String [] MIMETypes = { "image/gif" }; 33 34 private static final String readerClassName = 35 "com.sun.imageio.plugins.gif.GIFImageReader"; 36 37 private static final String [] writerSpiNames = null; 38 39 public GIFImageReaderSpi() { 40 super(vendorName, 41 version, 42 names, 43 suffixes, 44 MIMETypes, 45 readerClassName, 46 STANDARD_INPUT_TYPE, 47 writerSpiNames, 48 true, 49 GIFStreamMetadata.nativeMetadataFormatName, 50 "com.sun.imageio.plugins.gif.GIFStreamMetadataFormat", 51 null, null, 52 true, 53 GIFImageMetadata.nativeMetadataFormatName, 54 "com.sun.imageio.plugins.gif.GIFImageMetadataFormat", 55 null, null 56 ); 57 } 58 59 public String getDescription(Locale locale) { 60 return "Standard GIF image reader"; 61 } 62 63 public boolean canDecodeInput(Object input) throws IOException { 64 if (!(input instanceof ImageInputStream )) { 65 return false; 66 } 67 68 ImageInputStream stream = (ImageInputStream )input; 69 byte[] b = new byte[6]; 70 stream.mark(); 71 stream.readFully(b); 72 stream.reset(); 73 74 return b[0] == 'G' && b[1] == 'I' && b[2] == 'F' && b[3] == '8' && 75 (b[4] == '7' || b[4] == '9') && b[5] == 'a'; 76 } 77 78 public ImageReader createReaderInstance(Object extension) { 79 return new GIFImageReader(this); 80 } 81 82 } 83 | Popular Tags |