KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > imageio > plugins > wbmp > WBMPImageWriterSpi


1 /*
2  * @(#)WBMPImageWriterSpi.java 1.3 04/05/05 05:42:00
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.imageio.plugins.wbmp;
9
10 import javax.imageio.spi.ImageWriterSpi JavaDoc;
11 import javax.imageio.spi.ServiceRegistry JavaDoc;
12 import javax.imageio.spi.IIORegistry JavaDoc;
13 import javax.imageio.ImageWriter JavaDoc;
14 import javax.imageio.ImageTypeSpecifier JavaDoc;
15 import javax.imageio.IIOException JavaDoc;
16
17 import java.awt.image.ColorModel JavaDoc;
18 import java.awt.image.IndexColorModel JavaDoc;
19 import java.awt.image.MultiPixelPackedSampleModel JavaDoc;
20 import java.awt.image.SampleModel JavaDoc;
21 import java.util.Locale JavaDoc;
22
23 public class WBMPImageWriterSpi extends ImageWriterSpi JavaDoc {
24     private static String JavaDoc [] readerSpiNames =
25         {"com.sun.imageio.plugins.wbmp.WBMPImageReaderSpi"};
26     private static String JavaDoc[] formatNames = {"wbmp", "WBMP"};
27     private static String JavaDoc[] entensions = {"wbmp"};
28     private static String JavaDoc[] 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 JavaDoc getDescription(Locale JavaDoc locale) {
48         return "Standard WBMP Image Writer";
49     }
50
51     public void onRegistration(ServiceRegistry JavaDoc registry,
52                                Class JavaDoc<?> category) {
53         if (registered) {
54             return;
55         }
56
57         registered = true;
58     }
59
60     public boolean canEncodeImage(ImageTypeSpecifier JavaDoc type) {
61         SampleModel JavaDoc sm = type.getSampleModel();
62         if (!(sm instanceof MultiPixelPackedSampleModel JavaDoc))
63             return false;
64         if (sm.getSampleSize(0) != 1)
65             return false;
66
67         return true;
68     }
69
70     public ImageWriter JavaDoc createWriterInstance(Object JavaDoc extension)
71         throws IIOException JavaDoc {
72         return new WBMPImageWriter(this);
73     }
74 }
75
Popular Tags