blob: bf25455920dc7d050559633a3168a73136b19fc1 [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17/**
18 * @author Rustem V. Rafikov
19 * @version $Revision: 1.3 $
20 */
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080021
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070022package javax.imageio.spi;
23
24import javax.imageio.stream.ImageInputStream;
25import javax.imageio.ImageTypeSpecifier;
26import javax.imageio.ImageWriter;
27import java.awt.image.RenderedImage;
28import java.io.IOException;
29
30/**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080031 * The ImageWriterSpi abstract class is a service provider interface (SPI) for
32 * ImageWriters.
33 *
34 * @since Android 1.0
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070035 */
36public abstract class ImageWriterSpi extends ImageReaderWriterSpi {
37
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080038 /**
39 * The STANDARD_OUTPUT_TYPE contains ImageInputStream.class.
40 */
41 public static final Class[] STANDARD_OUTPUT_TYPE = new Class[] {
42 ImageInputStream.class
43 };
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070044
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080045 /**
46 * The output types.
47 */
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070048 protected Class[] outputTypes;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080049
50 /**
51 * The reader SPI names.
52 */
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070053 protected String[] readerSpiNames;
54
55 /**
56 * Instantiates a new ImageWriterSpi.
57 */
58 protected ImageWriterSpi() {
59 throw new UnsupportedOperationException("Not supported yet");
60 }
61
62 /**
63 * Instantiates a new ImageWriterSpi with the specified parameters.
64 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080065 * @param vendorName
66 * the vendor name.
67 * @param version
68 * the version.
69 * @param names
70 * the format names.
71 * @param suffixes
72 * the array of strings representing the file suffixes.
73 * @param MIMETypes
74 * the an array of strings representing MIME types.
75 * @param pluginClassName
76 * the plug-in class name.
77 * @param outputTypes
78 * the output types.
79 * @param readerSpiNames
80 * the array of strings with class names of all associated
81 * ImageReaders.
82 * @param supportsStandardStreamMetadataFormat
83 * the value indicating if stream metadata can be described by
84 * standard metadata format.
85 * @param nativeStreamMetadataFormatName
86 * the native stream metadata format name, returned by
87 * getNativeStreamMetadataFormatName.
88 * @param nativeStreamMetadataFormatClassName
89 * the native stream metadata format class name, returned by
90 * getNativeStreamMetadataFormat.
91 * @param extraStreamMetadataFormatNames
92 * the extra stream metadata format names, returned by
93 * getExtraStreamMetadataFormatNames.
94 * @param extraStreamMetadataFormatClassNames
95 * the extra stream metadata format class names, returned by
96 * getStreamMetadataFormat.
97 * @param supportsStandardImageMetadataFormat
98 * the value indicating if image metadata can be described by
99 * standard metadata format.
100 * @param nativeImageMetadataFormatName
101 * the native image metadata format name, returned by
102 * getNativeImageMetadataFormatName.
103 * @param nativeImageMetadataFormatClassName
104 * the native image metadata format class name, returned by
105 * getNativeImageMetadataFormat.
106 * @param extraImageMetadataFormatNames
107 * the extra image metadata format names, returned by
108 * getExtraImageMetadataFormatNames.
109 * @param extraImageMetadataFormatClassNames
110 * the extra image metadata format class names, returned by
111 * getImageMetadataFormat.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700112 */
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800113 public ImageWriterSpi(String vendorName, String version, String[] names, String[] suffixes,
114 String[] MIMETypes, String pluginClassName, Class[] outputTypes,
115 String[] readerSpiNames, boolean supportsStandardStreamMetadataFormat,
116 String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName,
117 String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames,
118 boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName,
119 String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames,
120 String[] extraImageMetadataFormatClassNames) {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700121 super(vendorName, version, names, suffixes, MIMETypes, pluginClassName,
122 supportsStandardStreamMetadataFormat, nativeStreamMetadataFormatName,
123 nativeStreamMetadataFormatClassName, extraStreamMetadataFormatNames,
124 extraStreamMetadataFormatClassNames, supportsStandardImageMetadataFormat,
125 nativeImageMetadataFormatName, nativeImageMetadataFormatClassName,
126 extraImageMetadataFormatNames, extraImageMetadataFormatClassNames);
127
128 if (outputTypes == null || outputTypes.length == 0) {
129 throw new NullPointerException("output types array cannot be NULL or empty");
130 }
131
132 this.outputTypes = outputTypes;
133 this.readerSpiNames = readerSpiNames;
134 }
135
136 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800137 * Returns true if the format of the writer's output is lossless. The
138 * default implementation returns true.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700139 *
140 * @return true, if a format is lossless, false otherwise.
141 */
142 public boolean isFormatLossless() {
143 return true;
144 }
145
146 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800147 * Gets an array of Class objects whose types can be used as output for this
148 * writer.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700149 *
150 * @return the output types.
151 */
152 public Class[] getOutputTypes() {
153 return outputTypes;
154 }
155
156 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800157 * Checks whether or not the ImageWriter implementation associated with this
158 * service provider can encode an image with the specified type.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700159 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800160 * @param type
161 * the ImageTypeSpecifier.
162 * @return true, if an image with the specified type can be encoded, false
163 * otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700164 */
165 public abstract boolean canEncodeImage(ImageTypeSpecifier type);
166
167 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800168 * Checks whether or not the ImageWriter implementation associated with this
169 * service provider can encode the specified RenderedImage.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700170 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800171 * @param im
172 * the RenderedImage.
173 * @return true, if RenderedImage can be encoded, false otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700174 */
175 public boolean canEncodeImage(RenderedImage im) {
176 return canEncodeImage(ImageTypeSpecifier.createFromRenderedImage(im));
177 }
178
179 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800180 * Returns an instance of the ImageWriter implementation for this service
181 * provider.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700182 *
183 * @return the ImageWriter.
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800184 * @throws IOException
185 * if an I/O exception has occurred.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700186 */
187 public ImageWriter createWriterInstance() throws IOException {
188 return createWriterInstance(null);
189 }
190
191 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800192 * Returns an instance of the ImageWriter implementation for this service
193 * provider.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700194 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800195 * @param extension
196 * the a plug-in specific extension object, or null.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700197 * @return the ImageWriter.
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800198 * @throws IOException
199 * if an I/O exception has occurred.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700200 */
201 public abstract ImageWriter createWriterInstance(Object extension) throws IOException;
202
203 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800204 * Checks whether or not the specified ImageWriter object is an instance of
205 * the ImageWriter associated with this service provider or not.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700206 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800207 * @param writer
208 * the ImageWriter.
209 * @return true, if the specified ImageWriter object is an instance of the
210 * ImageWriter associated with this service provider, false
211 * otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700212 */
213 public boolean isOwnWriter(ImageWriter writer) {
214 throw new UnsupportedOperationException("Not supported yet");
215 }
216
217 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800218 * Gets an array of strings with names of the ImageReaderSpi classes that
219 * support the internal metadata representation used by the ImageWriter of
220 * this service provider, or null if there are no such ImageReaders.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700221 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800222 * @return the array of strings with names of the ImageWriterSpi classes.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700223 */
224 public String[] getImageReaderSpiNames() {
225 return readerSpiNames;
226 }
227}