|
Spec-Zone .ru
спецификации, руководства, описания, API
|
public abstract class ImageWriterSpi extends ImageReaderWriterSpi
ImageWriters. Для получения дополнительной информации по классам поставщика услуг см. комментарий class для IIORegistry class. Каждый ImageWriterSpi обеспечивает несколько типов информации о ImageWriter class, с которым это связывается.
Имя поставщика, который определил SPI class и краткое описание class, доступно через getVendorName, getDescription, и getVersion методы. Эти методы могут интернационализироваться, чтобы обеспечить специфичный для локали вывод. Эти методы предназначаются, главным образом, чтобы предоставить короткую, человечески-перезаписываемую информацию, которая могла бы использоваться, чтобы организовать раскрывающееся меню или другой список.
Списки имен формата, суффиксов файла, и типов MIME, связанных со службой, могут быть получены посредством getFormatNames, getFileSuffixes, и getMIMEType методы. Эти методы могут использоваться, чтобы идентифицировать кандидата ImageWriters для того, чтобы записать определенный файл или поток, основанный на ручном выборе формата, именовании файла, или ассоциациях MIME.
Более надежный способ определить, который ImageWriters, вероятно, будут в состоянии проанализировать определенный поток данных, обеспечивается canEncodeImage метод. Это методы позволяет поставщику услуг осматривать фактическое содержание изображения.
Наконец, экземпляр ImageWriter class, связанный с этим поставщиком услуг, может быть получен, вызывая createWriterInstance метод. Любая тяжелая инициализация, такая как загрузка собственных библиотек или создание больших таблиц, должна быть задержана, по крайней мере, до первого вызова этого метода.
IIORegistry, ImageTypeSpecifier, ImageWriter| Модификатор и Тип | Поле и Описание |
|---|---|
protected Class[] |
outputTypes
Массив
Class объекты, которые будут возвращены из getOutputTypes, первоначально null. |
protected String[] |
readerSpiNames
Массив строк, которые будут возвращены из
getImageReaderSpiNames, первоначально null. |
static Class[] |
STANDARD_OUTPUT_TYPE
Осуждаемый.
Вместо того, чтобы использовать это поле, непосредственно создайте эквивалентный массив
{ ImageOutputStream.class } |
extraImageMetadataFormatClassNames, extraImageMetadataFormatNames, extraStreamMetadataFormatClassNames, extraStreamMetadataFormatNames, MIMETypes, names, nativeImageMetadataFormatClassName, nativeImageMetadataFormatName, nativeStreamMetadataFormatClassName, nativeStreamMetadataFormatName, pluginClassName, suffixes, supportsStandardImageMetadataFormat, supportsStandardStreamMetadataFormatvendorName, version| Modifier | Constructor and Description |
|---|---|
protected |
ImageWriterSpi()
Constructs a blank
ImageWriterSpi. |
|
ImageWriterSpi(String vendorName, String version, String[] names, String[] suffixes, String[] MIMETypes, String writerClassName, Class[] outputTypes, String[] readerSpiNames, boolean supportsStandardStreamMetadataFormat, String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName, String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames, boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName, String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames, String[] extraImageMetadataFormatClassNames)
Constructs an
ImageWriterSpi with a given set of values. |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
canEncodeImage(ImageTypeSpecifier type)
Returns
true if the ImageWriter implementation associated with this service provider is able to encode an image with the given layout. |
boolean |
canEncodeImage(RenderedImage im)
Returns
true if the ImageWriter implementation associated with this service provider is able to encode the given RenderedImage instance. |
ImageWriter |
createWriterInstance()
Returns an instance of the
ImageWriter implementation associated with this service provider. |
abstract ImageWriter |
createWriterInstance(Object extension)
Returns an instance of the
ImageWriter implementation associated with this service provider. |
Строка[] |
getImageReaderSpiNames()
Returns an array of
Strings containing all the fully qualified names of all the ImageReaderSpi classes that can understand the internal metadata representation used by the ImageWriter associated with this service provider, or null if there are no such ImageReaders specified. |
Класс[] |
getOutputTypes()
Returns an array of
Class objects indicating what types of objects may be used as arguments to the writer's setOutput method. |
boolean |
isFormatLossless()
Returns
true if the format that this writer outputs preserves pixel data bit-accurately. |
boolean |
isOwnWriter(ImageWriter writer)
Returns
true if the ImageWriter object passed in is an instance of the ImageWriter associated with this service provider. |
getExtraImageMetadataFormatNames, getExtraStreamMetadataFormatNames, getFileSuffixes, getFormatNames, getImageMetadataFormat, getMIMETypes, getNativeImageMetadataFormatName, getNativeStreamMetadataFormatName, getPluginClassName, getStreamMetadataFormat, isStandardImageMetadataFormatSupported, isStandardStreamMetadataFormatSupportedgetDescription, getVendorName, getVersion, onDeregistration, onRegistration@Deprecated public static final Class[] STANDARD_OUTPUT_TYPE
{ ImageOutputStream.class }.ImageOutputStream.class, to be returned from getOutputTypes.protected Class[] outputTypes
Class objects to be returned from getOutputTypes, initially null.protected String[] readerSpiNames
getImageReaderSpiNames, initially null.protected ImageWriterSpi()
ImageWriterSpi. It is up to the subclass to initialize instance variables and/or override method implementations in order to provide working versions of all methods.public ImageWriterSpi(String vendorName, String version, String[] names, String[] suffixes, String[] MIMETypes, String writerClassName, Class[] outputTypes, String[] readerSpiNames, boolean supportsStandardStreamMetadataFormat, String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName, String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames, boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName, String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames, String[] extraImageMetadataFormatClassNames)
ImageWriterSpi with a given set of values.vendorName - the vendor name, as a non-null
String.version - a version identifier, as a non-null
String.names - a non-null array of Strings indicating the format names. At least one entry must be present.suffixes - an array of Strings indicating the common file suffixes. If no suffixes are defined, null should be supplied. An array of length 0 will be normalized to null.MIMETypes - an array of Strings indicating the format's MIME types. If no suffixes are defined, null should be supplied. An array of length 0 will be normalized to null.writerClassName - the fully-qualified name of the associated ImageWriterSpi class, as a non-null String.outputTypes - an array of Class objects of length at least 1 indicating the legal output types.readerSpiNames - an array Strings of length at least 1 naming the classes of all associated ImageReaders, or null. An array of length 0 is normalized to null.supportsStandardStreamMetadataFormat - a boolean that indicates whether a stream metadata object can use trees described by the standard metadata format.nativeStreamMetadataFormatName - a String, or null, to be returned from getNativeStreamMetadataFormatName.nativeStreamMetadataFormatClassName - a String, or null, to be used to instantiate a metadata format object to be returned from getNativeStreamMetadataFormat.extraStreamMetadataFormatNames - an array of Strings, or null, to be returned from getExtraStreamMetadataFormatNames. An array of length 0 is normalized to null.extraStreamMetadataFormatClassNames - an array of Strings, or null, to be used to instantiate a metadata format object to be returned from getStreamMetadataFormat. An array of length 0 is normalized to null.supportsStandardImageMetadataFormat - a boolean that indicates whether an image metadata object can use trees described by the standard metadata format.nativeImageMetadataFormatName - a String, or null, to be returned from getNativeImageMetadataFormatName.nativeImageMetadataFormatClassName - a String, or null, to be used to instantiate a metadata format object to be returned from getNativeImageMetadataFormat.extraImageMetadataFormatNames - an array of Strings to be returned from getExtraImageMetadataFormatNames. An array of length 0 is normalized to null.extraImageMetadataFormatClassNames - an array of Strings, or null, to be used to instantiate a metadata format object to be returned from getImageMetadataFormat. An array of length 0 is normalized to null.IllegalArgumentException - if vendorName is null.IllegalArgumentException - if version is null.IllegalArgumentException - if names is null or has length 0.IllegalArgumentException - if writerClassName is null.IllegalArgumentException - if outputTypes is null or has length 0.public boolean isFormatLossless()
true if the format that this writer outputs preserves pixel data bit-accurately. The default implementation returns true.true if the format preserves full pixel accuracy.public Class[] getOutputTypes()
Class objects indicating what types of objects may be used as arguments to the writer's setOutput method. For most writers, which only output to an ImageOutputStream, a single-element array containing ImageOutputStream.class should be returned.
null array of Classobjects of length at least 1.public abstract boolean canEncodeImage(ImageTypeSpecifier type)
true if the ImageWriter implementation associated with this service provider is able to encode an image with the given layout. The layout (i.e., the image's SampleModel and ColorModel) is described by an ImageTypeSpecifier object. A return value of true is not an absolute guarantee of successful encoding; the encoding process may still produce errors due to factors such as I/O errors, inconsistent or malformed data structures, etc. The intent is that a reasonable inspection of the basic structure of the image be performed in order to determine if it is within the scope of the encoding format. For example, a service provider for a format that can only encode greyscale would return false if handed an RGB BufferedImage. Similarly, a service provider for a format that can encode 8-bit RGB imagery might refuse to encode an image with an associated alpha channel.
Different ImageWriters, and thus service providers, may choose to be more or less strict. For example, they might accept an image with premultiplied alpha even though it will have to be divided out of each pixel, at some loss of precision, in order to be stored.
type - an ImageTypeSpecifier specifying the layout of the image to be written.true if this writer is likely to be able to encode images with the given layout.IllegalArgumentException - if type is null.public boolean canEncodeImage(RenderedImage im)
true if the ImageWriter implementation associated with this service provider is able to encode the given RenderedImage instance. Note that this includes instances of java.awt.image.BufferedImage. See the discussion for canEncodeImage(ImageTypeSpecifier) for information on the semantics of this method.
im - an instance of RenderedImage to be encoded.true if this writer is likely to be able to encode this image.IllegalArgumentException - if im is null.public ImageWriter createWriterInstance() throws IOException
ImageWriter implementation associated with this service provider. The returned object will initially be in an initial state as if its reset method had been called. The default implementation simply returns createWriterInstance(null).
ImageWriter instance.IOException - if an error occurs during loading, or initialization of the writer class, or during instantiation or initialization of the writer object.public abstract ImageWriter createWriterInstance(Object extension) throws IOException
ImageWriter implementation associated with this service provider. The returned object will initially be in an initial state as if its reset method had been called. An Object may be supplied to the plug-in at construction time. The nature of the object is entirely plug-in specific.
Typically, a plug-in will implement this method using code such as return new MyImageWriter(this).
extension - a plug-in specific extension object, which may be null.ImageWriter instance.IOException - if the attempt to instantiate the writer fails.IllegalArgumentException - if the ImageWriter's constructor throws an IllegalArgumentException to indicate that the extension object is unsuitable.public boolean isOwnWriter(ImageWriter writer)
true if the ImageWriter object passed in is an instance of the ImageWriter associated with this service provider.writer - an ImageWriter instance.true if writer is recognizedIllegalArgumentException - if writer is null.public String[] getImageReaderSpiNames()
Strings containing all the fully qualified names of all the ImageReaderSpi classes that can understand the internal metadata representation used by the ImageWriter associated with this service provider, or null if there are no such ImageReaders specified. If a non-null value is returned, it must have non-zero length. The first item in the array must be the name of the service provider for the "preferred" reader, as it will be used to instantiate the ImageReader returned by ImageIO.getImageReader(ImageWriter).
This mechanism may be used to obtain ImageReaders that will generated non-pixel meta-data (see IIOExtraDataInfo) in a structure understood by an ImageWriter. By reading the image and obtaining this data from one of the ImageReaders obtained with this method and passing it on to the ImageWriter, a client program can read an image, modify it in some way, and write it back out preserving all meta-data, without having to understand anything about the internal structure of the meta-data, or even about the image format.
Strings of length at least 1 containing names of ImageReaderSpis, or null.ImageIO.getImageReader(ImageWriter), ImageReaderSpi.getImageWriterSpiNames()
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.
DRAFT ea-b92