1 7 8 package javax.imageio.spi; 9 10 import java.awt.image.RenderedImage ; 11 import java.io.IOException ; 12 import javax.imageio.ImageTypeSpecifier ; 13 import javax.imageio.ImageWriter ; 14 import javax.imageio.stream.ImageOutputStream ; 15 16 59 public abstract class ImageWriterSpi extends ImageReaderWriterSpi { 60 61 66 public static final Class [] STANDARD_OUTPUT_TYPE = 67 { ImageOutputStream .class }; 68 69 73 protected Class [] outputTypes = null; 74 75 80 protected String [] readerSpiNames = null; 81 82 86 private Class writerClass = null; 87 88 94 protected ImageWriterSpi() { 95 } 96 97 175 public ImageWriterSpi(String vendorName, 176 String version, 177 String [] names, 178 String [] suffixes, 179 String [] MIMETypes, 180 String writerClassName, 181 Class [] outputTypes, 182 String [] readerSpiNames, 183 boolean supportsStandardStreamMetadataFormat, 184 String nativeStreamMetadataFormatName, 185 String nativeStreamMetadataFormatClassName, 186 String [] extraStreamMetadataFormatNames, 187 String [] extraStreamMetadataFormatClassNames, 188 boolean supportsStandardImageMetadataFormat, 189 String nativeImageMetadataFormatName, 190 String nativeImageMetadataFormatClassName, 191 String [] extraImageMetadataFormatNames, 192 String [] extraImageMetadataFormatClassNames) { 193 super(vendorName, version, 194 names, suffixes, MIMETypes, writerClassName, 195 supportsStandardStreamMetadataFormat, 196 nativeStreamMetadataFormatName, 197 nativeStreamMetadataFormatClassName, 198 extraStreamMetadataFormatNames, 199 extraStreamMetadataFormatClassNames, 200 supportsStandardImageMetadataFormat, 201 nativeImageMetadataFormatName, 202 nativeImageMetadataFormatClassName, 203 extraImageMetadataFormatNames, 204 extraImageMetadataFormatClassNames); 205 206 if (outputTypes == null) { 207 throw new IllegalArgumentException 208 ("outputTypes == null!"); 209 } 210 if (outputTypes.length == 0) { 211 throw new IllegalArgumentException 212 ("outputTypes.length == 0!"); 213 } 214 this.outputTypes = (Class [])outputTypes.clone(); 215 if (readerSpiNames != null && readerSpiNames.length > 0) { 217 this.readerSpiNames = (String [])readerSpiNames.clone(); 218 } 219 } 220 221 229 public boolean isFormatLossless() { 230 return true; 231 } 232 233 246 public Class [] getOutputTypes() { 247 return (Class [])outputTypes.clone(); 248 } 249 250 286 public abstract boolean canEncodeImage(ImageTypeSpecifier type); 287 288 307 public boolean canEncodeImage(RenderedImage im) { 308 return canEncodeImage(ImageTypeSpecifier.createFromRenderedImage(im)); 309 } 310 311 326 public ImageWriter createWriterInstance() throws IOException { 327 return createWriterInstance(null); 328 } 329 330 355 public abstract ImageWriter createWriterInstance(Object extension) 356 throws IOException ; 357 358 370 public boolean isOwnWriter(ImageWriter writer) { 371 if (writer == null) { 372 throw new IllegalArgumentException ("writer == null!"); 373 } 374 String name = writer.getClass().getName(); 375 return name.equals(pluginClassName); 376 } 377 378 412 public String [] getImageReaderSpiNames() { 413 return readerSpiNames == null ? 414 null : (String [])readerSpiNames.clone(); 415 } 416 } 417 | Popular Tags |