Class ImageIOImageWriter
java.lang.Object
org.apache.xmlgraphics.image.writer.imageio.ImageIOImageWriter
- All Implemented Interfaces:
EventListener
,IIOWriteWarningListener
,ImageWriter
- Direct Known Subclasses:
ImageIOJPEGImageWriter
,ImageIOPNGImageWriter
,ImageIOTIFFImageWriter
ImageWriter implementation that uses Image I/O to write images.
- Version:
- $Id$
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a MultiImageWriter instance that lets you put multiple pages into a single file if the format supports it.protected IIOMetadata
createStreamMetadata
(ImageWriter writer, ImageWriteParam writeParam, ImageWriterParams params) Creates the stream metadata for image.protected static IIOMetadataNode
getChildNode
(Node n, String name) Returns a specific metadata child nodeprotected ImageWriteParam
getDefaultWriteParam
(ImageWriter iiowriter, RenderedImage image, ImageWriterParams params) Returns the default write parameters for encoding the image.boolean
boolean
protected IIOMetadata
updateMetadata
(RenderedImage image, IIOMetadata meta, ImageWriterParams params) Updates the metadata information based on the parameters to this writer.void
warningOccurred
(ImageWriter source, int imageIndex, String warning) void
writeImage
(RenderedImage image, OutputStream out) Encodes an image and writes it to an OutputStream.void
writeImage
(RenderedImage image, OutputStream out, ImageWriterParams params) Encodes an image and writes it to an OutputStream.
-
Constructor Details
-
ImageIOImageWriter
Main constructor.- Parameters:
mime
- the MIME type of the image format
-
-
Method Details
-
writeImage
Encodes an image and writes it to an OutputStream.- Specified by:
writeImage
in interfaceImageWriter
- Parameters:
image
- the image to be encodedout
- the OutputStream to write to- Throws:
IOException
- In case of an /IO problem
-
writeImage
public void writeImage(RenderedImage image, OutputStream out, ImageWriterParams params) throws IOException Encodes an image and writes it to an OutputStream.- Specified by:
writeImage
in interfaceImageWriter
- Parameters:
image
- the image to be encodedout
- the OutputStream to write toparams
- a parameters object to customize the encoding.- Throws:
IOException
- In case of an /IO problem
-
createStreamMetadata
protected IIOMetadata createStreamMetadata(ImageWriter writer, ImageWriteParam writeParam, ImageWriterParams params) Creates the stream metadata for image. By default, this method returns null which causes the default stream metadata to be used. Subclasses can override this to supply special stream metadata (see TIFF for an example).- Parameters:
writer
- the image writewriteParam
- the ImageIO write parametersparams
- the ImageWriter write parameters- Returns:
- the stream metadata (or null if no special metadata needs to be produced)
-
getDefaultWriteParam
protected ImageWriteParam getDefaultWriteParam(ImageWriter iiowriter, RenderedImage image, ImageWriterParams params) Returns the default write parameters for encoding the image.- Parameters:
iiowriter
- The IIO ImageWriter that will be usedimage
- the image to be encodedparams
- the parameters for this writer instance- Returns:
- the IIO ImageWriteParam instance
-
updateMetadata
protected IIOMetadata updateMetadata(RenderedImage image, IIOMetadata meta, ImageWriterParams params) Updates the metadata information based on the parameters to this writer.- Parameters:
image
- the current image being renderedmeta
- the metadataparams
- the parameters- Returns:
- the updated metadata
-
getChildNode
Returns a specific metadata child node- Parameters:
n
- the base nodename
- the name of the child- Returns:
- the requested child node
-
getMIMEType
- Specified by:
getMIMEType
in interfaceImageWriter
- Returns:
- the target MIME type supported by this ImageWriter
-
isFunctional
public boolean isFunctional()- Specified by:
isFunctional
in interfaceImageWriter
- Returns:
- true if the ImageWriter is expected to work properly in the current environment
-
warningOccurred
- Specified by:
warningOccurred
in interfaceIIOWriteWarningListener
-
createMultiImageWriter
Creates a MultiImageWriter instance that lets you put multiple pages into a single file if the format supports it.- Specified by:
createMultiImageWriter
in interfaceImageWriter
- Parameters:
out
- the OutputStream to write the image to- Returns:
- the requested MultiImageWriter instance
- Throws:
IOException
- In case of an /IO problem
-
supportsMultiImageWriter
public boolean supportsMultiImageWriter()- Specified by:
supportsMultiImageWriter
in interfaceImageWriter
- Returns:
- true if the implemented format supports multiple pages in a single file
-