1 7 8 package com.sun.imageio.plugins.wbmp; 9 10 import javax.imageio.spi.ImageWriterSpi ; 11 import javax.imageio.spi.ServiceRegistry ; 12 import javax.imageio.spi.IIORegistry ; 13 import javax.imageio.ImageWriter ; 14 import javax.imageio.ImageTypeSpecifier ; 15 import javax.imageio.IIOException ; 16 17 import java.awt.image.ColorModel ; 18 import java.awt.image.IndexColorModel ; 19 import java.awt.image.MultiPixelPackedSampleModel ; 20 import java.awt.image.SampleModel ; 21 import java.util.Locale ; 22 23 public class WBMPImageWriterSpi extends ImageWriterSpi { 24 private static String [] readerSpiNames = 25 {"com.sun.imageio.plugins.wbmp.WBMPImageReaderSpi"}; 26 private static String [] formatNames = {"wbmp", "WBMP"}; 27 private static String [] entensions = {"wbmp"}; 28 private static String [] mimeType = {"image/vnd.wap.wbmp"}; 29 30 private boolean registered = false; 31 32 public WBMPImageWriterSpi() { 33 super("Sun Microsystems, Inc.", 34 "1.0", 35 formatNames, 36 entensions, 37 mimeType, 38 "com.sun.imageio.plugins.wbmp.WBMPImageWriter", 39 STANDARD_OUTPUT_TYPE, 40 readerSpiNames, 41 true, 42 null, null, null, null, 43 true, 44 null, null, null, null); 45 } 46 47 public String getDescription(Locale locale) { 48 return "Standard WBMP Image Writer"; 49 } 50 51 public void onRegistration(ServiceRegistry registry, 52 Class <?> category) { 53 if (registered) { 54 return; 55 } 56 57 registered = true; 58 } 59 60 public boolean canEncodeImage(ImageTypeSpecifier type) { 61 SampleModel sm = type.getSampleModel(); 62 if (!(sm instanceof MultiPixelPackedSampleModel )) 63 return false; 64 if (sm.getSampleSize(0) != 1) 65 return false; 66 67 return true; 68 } 69 70 public ImageWriter createWriterInstance(Object extension) 71 throws IIOException { 72 return new WBMPImageWriter(this); 73 } 74 } 75 | Popular Tags |