Imagewriter Java - Part1
Imagewriter Java - Part1
java.lang.Object
javax.imageio.ImageWriter
All Implemented Interfaces:
ImageTranscoder
An abstract superclass for encoding and writing images. This class must be subclassed by
classes that write out images in the context of the Java Image I/O framework.
ImageWriter objects are normally instantiated by the service provider class for the specific
format. Service provider classes are registered with the IIORegistry, which uses them for
format recognition and presentation of available format readers and writers.
See Also:
ImageReader
ImageWriteParam
IIORegistry
ImageWriterSpi
Field Summary
Fields
Modifier and Type
Field
Description
protected Locale[]
availableLocales
An array of Locales that may be used to localize warning messages and compression
setting values, or null if localization is not supported.
protected Locale
locale
The current Locale to be used for localization, or null if none has been set.
protected ImageWriterSpi
originatingProvider
The ImageWriterSpi that instantiated this object, or null if its identity is not known
or none exists.
protected Object
output
protected List<IIOWriteProgressListener>
progressListeners
protected List<IIOWriteWarningListener>
warningListeners
protected List<Locale>
warningLocales
Constructor Summary
Constructors
Modifier
Constructor
Description
protected
ImageWriter(ImageWriterSpi originatingProvider)
Method
Description
void
abort()
protected boolean
abortRequested()
Returns true if a request to abort the current write operation has been made since the
writer was instantiated or clearAbortRequest was called.
void
addIIOWriteProgressListener(IIOWriteProgressListener listener)
void
addIIOWriteWarningListener(IIOWriteWarningListener listener)
boolean
canInsertEmpty(int imageIndex)
Returns true if the writer supports the insertion of a new, empty image at the given
index.
boolean
canInsertImage(int imageIndex)
Returns true if the writer supports the insertion of a new image at the given index.
boolean
canRemoveImage(int imageIndex)
Returns true if the writer supports the removal of an existing image at the given index.
boolean
canReplaceImageMetadata(int imageIndex)
Returns true if it is possible to replace the image metadata associated with an existing
image with index imageIndex.
boolean
canReplacePixels(int imageIndex)
Returns true if the writer allows pixels of the given image to be replaced using the
replacePixels methods.
boolean
canReplaceStreamMetadata()
Returns true if it is possible to replace the stream metadata already present in the
output.
boolean
canWriteEmpty()
Returns true if the writer supports the writing of a complete image stream consisting
of a single image with undefined pixel values and associated metadata and thumbnails
to the output.
boolean
canWriteRasters()
Returns true if the methods that take an IIOImage parameter are capable of dealing
with a Raster (as opposed to RenderedImage) source image.
boolean
canWriteSequence()
Returns true if the writer is able to append an image to an image stream that already
contains header information and possibly prior images.
protected void
clearAbortRequest()
void
dispose()
void
endInsertEmpty()
Completes the insertion of a new image that was begun with a prior call to
prepareInsertEmpty.
void
endReplacePixels()
void
endWriteEmpty()
Completes the writing of a new image that was begun with a prior call to
prepareWriteEmpty.
void
endWriteSequence()
Locale[]
getAvailableLocales()
Returns an array of Locales that may be used to localize warning listeners and
compression settings.
abstract IIOMetadata
getDefaultImageMetadata(ImageTypeSpecifier imageType,
ImageWriteParam param)
Returns an IIOMetadata object containing default values for encoding an image of the
given type.
abstract IIOMetadata
getDefaultStreamMetadata(ImageWriteParam param)
ImageWriteParam
getDefaultWriteParam()
Returns a new ImageWriteParam object of the appropriate type for this file format
containing default values, that is, those values that would be used if no
ImageWriteParam object were specified.
Locale
getLocale()
Returns the currently set Locale, or null if none has been set.
int
getNumThumbnailsSupported(ImageTypeSpecifier imageType,
ImageWriteParam param, IIOMetadata streamMetadata, IIOMetadata
imageMetadata)
Returns the number of thumbnails supported by the format being written, given the
image type and any additional write parameters and metadata objects that will be used
during encoding.
ImageWriterSpi
getOriginatingProvider()
Returns the ImageWriterSpi object that created this ImageWriter, or null if this
object was not created through the IIORegistry.
Object
getOutput()
Returns the ImageOutputStream or other Object set by the most recent call to the
setOutput method.
Dimension[]
getPreferredThumbnailSizes(ImageTypeSpecifier imageType,
ImageWriteParam param, IIOMetadata streamMetadata, IIOMetadata
imageMetadata)
Returns an array of Dimensions indicating the legal size ranges for thumbnail images
as they will be encoded in the output file or stream.
void
Begins the insertion of a new image with undefined pixel values into an existing image
stream.
void
void
Begins the writing of a complete image stream, consisting of a single image with
undefined pixel values and associated metadata and thumbnails, to the output.
void
prepareWriteSequence(IIOMetadata streamMetadata)
protected void
processImageComplete()
protected void
processImageProgress(float percentageDone)
protected void
processImageStarted(int imageIndex)
protected void
processThumbnailComplete()
protected void
processThumbnailProgress(float percentageDone)
protected void
protected void
protected void
processWriteAborted()
void
removeAllIIOWriteProgressListeners()
void
removeAllIIOWriteWarningListeners()
void
removeIIOWriteProgressListener(IIOWriteProgressListener listener)
void
removeIIOWriteWarningListener(IIOWriteWarningListener listener)
Removes an IIOWriteWarningListener from the list of registered warning
listeners.
void
removeImage(int imageIndex)
void
void
Replaces a portion of an image already present in the output with a portion of the given
Raster.
void
Replaces a portion of an image already present in the output with a portion of the given
image.
void
replaceStreamMetadata(IIOMetadata streamMetadata)
void
reset()
void
setLocale(Locale locale)
void
setOutput(Object output)
void
write(RenderedImage image)
Appends a complete image stream consisting of a single image with default metadata
and thumbnails to the output.
void
write(IIOImage image)
Appends a complete image stream containing a single image with default metadata and
thumbnails to the output.
abstract void
Appends a complete image stream containing a single image and associated stream and
image metadata and thumbnails to the output.
void
void
Appends a single image and possibly associated metadata and thumbnails, to the
output.
Field Details
originatingProvider
protected ImageWriterSpi originatingProvider
The ImageWriterSpi that instantiated this object, or null if its identity is not
known or none exists. By default it is initialized to null.
output
protected Object output
The ImageOutputStream or other Object set by setOutput and retrieved by
getOutput. By default it is initialized to null.
availableLocales
protected Locale[] availableLocales
An array of Locales that may be used to localize warning messages and
compression setting values, or null if localization is not supported. By default it
is initialized to null.
locale
protected Locale locale
The current Locale to be used for localization, or null if none has been set. By
default it is initialized to null.
warningListeners
protected List<IIOWriteWarningListener> warningListeners
A List of currently registered IIOWriteWarningListeners, initialized by
default to null, which is synonymous with an empty List.
warningLocales
protected List<Locale> warningLocales
A List of Locales, one for each element of warningListeners, initialized by
default null, which is synonymous with an empty List.
progressListeners
protected List<IIOWriteProgressListener> progressListeners
A List of currently registered IIOWriteProgressListeners, initialized by
default null, which is synonymous with an empty List.
Constructor Details
ImageWriter
protected ImageWriter(ImageWriterSpi originatingProvider)
Constructs an ImageWriter and sets its originatingProvider instance
variable to the supplied value.
Subclasses that make use of extensions should provide a constructor with
signature (ImageWriterSpi, Object) in order to retrieve the extension
object. If the extension object is unsuitable, an IllegalArgumentException
should be thrown.
Parameters:
originatingProvider - the ImageWriterSpi that is constructing this
object, or null.
Method Details
getOriginatingProvider
public ImageWriterSpi getOriginatingProvider()
Returns the ImageWriterSpi object that created this ImageWriter, or null
if this object was not created through the IIORegistry.
The default implementation returns the value of the originatingProvider
instance variable.
Returns:
an ImageWriterSpi, or null.
See Also:
ImageWriterSpi
setOutput