1 7 8 package com.sun.imageio.plugins.wbmp; 9 10 import java.util.Locale ; 11 import javax.imageio.spi.ImageReaderSpi ; 12 import javax.imageio.stream.ImageInputStream ; 13 import javax.imageio.spi.IIORegistry ; 14 import javax.imageio.spi.ServiceRegistry ; 15 import java.io.IOException ; 16 import javax.imageio.ImageReader ; 17 import javax.imageio.IIOException ; 18 19 public class WBMPImageReaderSpi extends ImageReaderSpi { 20 21 private static String [] writerSpiNames = 22 {"com.sun.imageio.plugins.wbmp.WBMPImageWriterSpi"}; 23 private static String [] formatNames = {"wbmp", "WBMP"}; 24 private static String [] entensions = {"wbmp"}; 25 private static String [] mimeType = {"image/vnd.wap.wbmp"}; 26 27 private boolean registered = false; 28 29 public WBMPImageReaderSpi() { 30 super("Sun Microsystems, Inc.", 31 "1.0", 32 formatNames, 33 entensions, 34 mimeType, 35 "com.sun.imageio.plugins.wbmp.WBMPImageReader", 36 STANDARD_INPUT_TYPE, 37 writerSpiNames, 38 true, 39 null, null, null, null, 40 true, 41 WBMPMetadata.nativeMetadataFormatName, 42 "com.sun.imageio.plugins.wbmp.WBMPMetadataFormat", 43 null, null); 44 } 45 46 public void onRegistration(ServiceRegistry registry, 47 Class <?> category) { 48 if (registered) { 49 return; 50 } 51 registered = true; 52 } 53 54 public String getDescription(Locale locale) { 55 return "Standard WBMP Image Reader"; 56 } 57 58 public boolean canDecodeInput(Object source) throws IOException { 59 if (!(source instanceof ImageInputStream )) { 60 return false; 61 } 62 63 ImageInputStream stream = (ImageInputStream )source; 64 byte[] b = new byte[3]; 65 66 stream.mark(); 67 stream.readFully(b); 68 stream.reset(); 69 70 return ((b[0] == (byte)0) && b[1] == 0 && ((b[2] & 0x8f) != 0 || (b[2] & 0x7f) != 0)); } 75 76 public ImageReader createReaderInstance(Object extension) 77 throws IIOException { 78 return new WBMPImageReader(this); 79 } 80 } 81 82 | Popular Tags |