ImageWriter
s.
For more information on service provider classes, see the class comment
for the IIORegistry
class.
Each ImageWriterSpi
provides several types of information
about the ImageWriter
class with which it is associated.
The name of the vendor who defined the SPI class and a
brief description of the class are available via the
getVendorName
, getDescription
,
and getVersion
methods.
These methods may be internationalized to provide locale-specific
output. These methods are intended mainly to provide short,
human-writable information that might be used to organize a pop-up
menu or other list.
Lists of format names, file suffixes, and MIME types associated
with the service may be obtained by means of the
getFormatNames
, getFileSuffixes
, and
getMIMEType
methods. These methods may be used to
identify candidate ImageWriter
s for writing a
particular file or stream based on manual format selection, file
naming, or MIME associations.
A more reliable way to determine which ImageWriter
s
are likely to be able to parse a particular data stream is provided
by the canEncodeImage
method. This methods allows the
service provider to inspect the actual image contents.
Finally, an instance of the ImageWriter
class
associated with this service provider may be obtained by calling
the createWriterInstance
method. Any heavyweight
initialization, such as the loading of native libraries or creation
of large tables, should be deferred at least until the first
invocation of this method.
ImageWriterSpi
with a given
set of values.ImageInputStream.class
, to be returned from
getInputTypes
.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 ImageWriter
s, 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.
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.
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
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)
.
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y) consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
Locale
, if possible.String
s containing the names
of additional document formats, other than the native and
standard formats, recognized by the
getAsTree
and setFromTree
methods on
the image metadata objects produced or consumed by this
plug-in.
If the plug-in does not handle image metadata, null should be returned.
The set of formats may differ according to the particular images being read or written; this method should indicate all the additional formats supported by the plug-in under any circumstances.
The default implementation returns a clone of the
extraImageMetadataFormatNames
instance variable,
which is typically set by the constructor.
String
s containing the names
of additional document formats, other than the native and
standard formats, recognized by the
getAsTree
and setFromTree
methods on
the stream metadata objects produced or consumed by this
plug-in.
If the plug-in does not handle metadata, null should be returned.
The set of formats may differ according to the particular images being read or written; this method should indicate all the additional formats supported by the plug-in under any circumstances.
The default implementation returns a clone of the
extraStreamMetadataFormatNames
instance variable,
which is typically set by the constructor.
String
s containing a list of
file suffixes associated with the formats that are generally
usable by the ImageReader
or
ImageWriter
implementation associated with this
service provider. For example, a single
ImageReader
might be able to process files with
'.pbm' and '.pnm' suffixes, or both '.jpg' and '.jpeg'
suffixes. If there are no known file suffixes,
null
will be returned.
Returning a particular suffix does not guarantee that files with that suffix can be processed; it merely indicates that it may be worthwhile attempting to decode or encode such files using this service provider.
String
s containing
human-readable names for the formats that are generally usable
by the ImageReader
or ImageWriter
implementation associated with this service provider. For
example, a single ImageReader
might be able to
process both PBM and PNM files.IIOMetadataFormat
object describing the
given image metadata format, or null
if no
description is available. The supplied name must be the native
iamge metadata format name, the standard metadata format name,
or one of those returned by
getExtraImageMetadataFormatNames
.String
s 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.
String
s containing a list of
MIME types associated with the formats that are generally
usable by the ImageReader
or
ImageWriter
implementation associated with this
service provider.
Ideally, only a single MIME type would be required in order
to describe a particular format. However, for several reasons
it is necessary to associate a list of types with each service
provider. First, many common image file formats do not have
standard MIME types, so a list of commonly used unofficial
names will be required, such as image/x-pbm
and
image/x-portable-bitmap
. Some file formats have
official MIME types but may sometimes be referred to using
their previous unofficial designations, such as
image/x-png
instead of the official
image/png
. Finally, a single service provider may
be capable of parsing multiple distinct types from the MIME
point of view, for example image/x-xbitmap
and
image/x-xpixmap
.
Returning a particular MIME type does not guarantee that files claiming to be of that type can be processed; it merely indicates that it may be worthwhile attempting to decode or encode such files using this service provider.
null
will be returned.
The default implementation returns the
nativeImageMetadataFormatName
instance variable,
which is typically set by the constructor.
null
will be returned.
The default implementation returns the
nativeStreamMetadataFormatName
instance variable,
which is typically set by the constructor.
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.
ImageReader
or ImageWriter
plug-in
associated with this service provider.IIOMetadataFormat
object describing the
given stream metadata format, or null
if no
description is available. The supplied name must be the native
stream metadata format name, the standard metadata format name,
or one of those returned by
getExtraStreamMetadataFormatNames
. The default implementation returns the value of the
vendorName
instance variable.
The default implementation returns the value of the
version
instance variable.
java.util.Hashtable
.
The general contract of hashCode
is:
hashCode
method on each of
the two objects must produce the same integer result.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
true
if the format that this writer
outputs preserves pixel data bit-accurately. The default
implementation returns true
.true
if the ImageWriter
object
passed in is an instance of the ImageWriter
associated with this service provider.true
if the standard metadata format is
among the document formats recognized by the
getAsTree
and setFromTree
methods on
the image metadata objects produced or consumed by this
plug-in.true
if the standard metadata format is
among the document formats recognized by the
getAsTree
and setFromTree
methods on
the stream metadata objects produced or consumed by this
plug-in.wait
methods.
The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
synchronized
statement
that synchronizes on the object.
Class,
by executing a
synchronized static method of that class.
Only one thread at a time can own an object's monitor.
wait
methods.
The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
ServiceRegistry
.
Only the registry should call this method.
The default implementation does nothing.
ServiceRegistry
. This may be used to verify that
the environment is suitable for this service, for example that
native libraries can be loaded. If the service cannot function
in the environment where it finds itself, it should deregister
itself from the registry.
Only the registry should call this method.
The default implementation does nothing.
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until another thread
notifies threads waiting on this object's monitor to wake up
either through a call to the notify
method or the
notifyAll
method. The thread then waits until it can
re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.The current thread must own this object's monitor.
This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:
A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout); ... // Perform action appropriate to condition }(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).
If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.
Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
This method is similar to the wait
method of one
argument, but it allows finer control over the amount of time to
wait for a notification before giving up. The amount of real time,
measured in nanoseconds, is given by:
1000000*timeout+nanos
In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:
notify
method
or the notifyAll
method.
timeout
milliseconds plus nanos
nanoseconds arguments, has
elapsed.
The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout, nanos); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.