author | henryjen |
Fri, 21 Feb 2014 15:28:37 -0800 | |
changeset 23312 | 4711f66e7d5c |
parent 7668 | d4a77089c587 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
7668 | 2 |
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.imageio.plugins.wbmp; |
|
27 |
||
28 |
import javax.imageio.spi.ImageWriterSpi; |
|
29 |
import javax.imageio.spi.ServiceRegistry; |
|
30 |
import javax.imageio.spi.IIORegistry; |
|
3447
7d593a130994
6656625: ImageReaderSpi.STANDARD_INPUT_TYPE/ImageWriterSpi.STANDARD_OUTPUT_TYPE are mutable static (findbugs)
bae
parents:
2
diff
changeset
|
31 |
import javax.imageio.stream.ImageOutputStream; |
2 | 32 |
import javax.imageio.ImageWriter; |
33 |
import javax.imageio.ImageTypeSpecifier; |
|
34 |
import javax.imageio.IIOException; |
|
35 |
||
36 |
import java.awt.image.ColorModel; |
|
37 |
import java.awt.image.IndexColorModel; |
|
38 |
import java.awt.image.MultiPixelPackedSampleModel; |
|
39 |
import java.awt.image.SampleModel; |
|
40 |
import java.util.Locale; |
|
41 |
||
42 |
public class WBMPImageWriterSpi extends ImageWriterSpi { |
|
43 |
private static String [] readerSpiNames = |
|
44 |
{"com.sun.imageio.plugins.wbmp.WBMPImageReaderSpi"}; |
|
45 |
private static String[] formatNames = {"wbmp", "WBMP"}; |
|
46 |
private static String[] entensions = {"wbmp"}; |
|
47 |
private static String[] mimeType = {"image/vnd.wap.wbmp"}; |
|
48 |
||
49 |
private boolean registered = false; |
|
50 |
||
51 |
public WBMPImageWriterSpi() { |
|
6816
6c2a27114265
6984033: imageio vendor references need to change (jdk7 only)
bae
parents:
5506
diff
changeset
|
52 |
super("Oracle Corporation", |
2 | 53 |
"1.0", |
54 |
formatNames, |
|
55 |
entensions, |
|
56 |
mimeType, |
|
57 |
"com.sun.imageio.plugins.wbmp.WBMPImageWriter", |
|
23312
4711f66e7d5c
8033716: Fix raw and unchecked lint warnings in com.sun.imageio
henryjen
parents:
7668
diff
changeset
|
58 |
new Class<?>[] { ImageOutputStream.class }, |
2 | 59 |
readerSpiNames, |
60 |
true, |
|
61 |
null, null, null, null, |
|
62 |
true, |
|
63 |
null, null, null, null); |
|
64 |
} |
|
65 |
||
66 |
public String getDescription(Locale locale) { |
|
67 |
return "Standard WBMP Image Writer"; |
|
68 |
} |
|
69 |
||
70 |
public void onRegistration(ServiceRegistry registry, |
|
71 |
Class<?> category) { |
|
72 |
if (registered) { |
|
73 |
return; |
|
74 |
} |
|
75 |
||
76 |
registered = true; |
|
77 |
} |
|
78 |
||
79 |
public boolean canEncodeImage(ImageTypeSpecifier type) { |
|
80 |
SampleModel sm = type.getSampleModel(); |
|
81 |
if (!(sm instanceof MultiPixelPackedSampleModel)) |
|
82 |
return false; |
|
83 |
if (sm.getSampleSize(0) != 1) |
|
84 |
return false; |
|
85 |
||
86 |
return true; |
|
87 |
} |
|
88 |
||
89 |
public ImageWriter createWriterInstance(Object extension) |
|
90 |
throws IIOException { |
|
91 |
return new WBMPImageWriter(this); |
|
92 |
} |
|
93 |
} |