APIdia Launch Partner
Top Fields Constructors Methods
com.sun.imageio.plugins.png

public final Class PNGImageWriter

Additional top-level classes in compilation unit: CRC, ChunkStream, IDATOutputStream, PNGImageWriteParam.

extends ImageWriter
Class Inheritance
Imports
java.awt.Rectangle, java.awt.image.BufferedImage, .IndexColorModel, .Raster, .RenderedImage, .SampleModel, .WritableRaster, java.io.ByteArrayOutputStream, .IOException, java.util.Iterator, .Locale, java.util.zip.Deflater, .DeflaterOutputStream, javax.imageio.IIOException, .IIOImage, .ImageTypeSpecifier, .ImageWriteParam, .ImageWriter, javax.imageio.metadata.IIOMetadata, javax.imageio.spi.ImageWriterSpi, javax.imageio.stream.ImageOutputStream, .ImageOutputStreamImpl

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv byte[]
private static final int
DEFAULT_COMPRESSION_LEVEL

Default compression level = 4 ie medium compression

pack-priv byte[][]
pack-priv PNGMetadata
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv byte[]
pack-priv RowFilter
pack-priv int[]
pack-priv byte[][]
pack-priv byte[]
pack-priv byte[][]
pack-priv byte[][]
pack-priv int
pack-priv int[]
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv ImageOutputStream
pack-priv int
Inherited from javax.imageio.ImageWriter:
availableLocaleslocaleoriginatingProvideroutputprogressListenerswarningListenerswarningLocales

Constructor Summary

AccessConstructor and Description
public
PNGImageWriter(ImageWriterSpi originatingProvider)

Method Summary

Modifier and TypeMethod and Description
private static int
chunkType(String typeString)

public IIOMetadata
convertImageMetadata(IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.convertImageMetadata.

Implements javax.imageio.ImageTranscoder.convertImageMetadata.

Returns an IIOMetadata object that may be used for encoding and optionally modified using its document interfaces or other interfaces specific to the writer plug-in that will be used for encoding.

public IIOMetadata
convertStreamMetadata(IIOMetadata inData, ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.convertStreamMetadata.

Implements javax.imageio.ImageTranscoder.convertStreamMetadata.

Returns an IIOMetadata object that may be used for encoding and optionally modified using its document interfaces or other interfaces specific to the writer plug-in that will be used for encoding.

private byte[]
deflate(byte[] b)

private void
encodePass(ImageOutputStream os, RenderedImage image, int xOffset, int yOffset, int xSkip, int ySkip)

private boolean
equals(int[] s0, int[] s1)

public IIOMetadata
getDefaultImageMetadata(ImageTypeSpecifier imageType, ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.getDefaultImageMetadata.

Returns an IIOMetadata object containing default values for encoding an image of the given type.

public IIOMetadata
getDefaultStreamMetadata(ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.getDefaultStreamMetadata.

Returns an IIOMetadata object containing default values for encoding a stream of images.

public ImageWriteParam
getDefaultWriteParam()

Overrides javax.imageio.ImageWriter.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.

private void
initializeScaleTables(int[] sampleSize)

public void
setOutput(Object output)

Overrides javax.imageio.ImageWriter.setOutput.

Sets the destination to the given ImageOutputStream or other Object.

public void
write(IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.write.

Appends a complete image stream containing a single image and associated stream and image metadata and thumbnails to the output.

private void
private void
private void
private void
private void
private void
write_IDAT(RenderedImage image, int deflaterLevel)

private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
Inherited from javax.imageio.ImageWriter:
abortabortRequestedaddIIOWriteProgressListeneraddIIOWriteWarningListenercanInsertEmptycanInsertImagecanRemoveImagecanReplaceImageMetadatacanReplacePixelscanReplaceStreamMetadatacanWriteEmptycanWriteRasterscanWriteSequenceclearAbortRequestdisposeendInsertEmptyendReplacePixelsendWriteEmptyendWriteSequencegetAvailableLocalesgetLocalegetNumThumbnailsSupportedgetOriginatingProvidergetOutputgetPreferredThumbnailSizesprepareInsertEmptyprepareReplacePixelsprepareWriteEmptyprepareWriteSequenceprocessImageCompleteprocessImageProgressprocessImageStartedprocessThumbnailCompleteprocessThumbnailProgressprocessThumbnailStartedprocessWarningOccurredprocessWarningOccurredprocessWriteAbortedremoveAllIIOWriteProgressListenersremoveAllIIOWriteWarningListenersremoveIIOWriteProgressListenerremoveIIOWriteWarningListenerremoveImagereplaceImageMetadatareplacePixelsreplacePixelsreplaceStreamMetadataresetsetLocalewritewritewriteInsertwriteToSequence

Field Detail

bppback to summary
pack-priv int bpp
currRowback to summary
pack-priv byte[] currRow
DEFAULT_COMPRESSION_LEVELback to summary
private static final int DEFAULT_COMPRESSION_LEVEL

Default compression level = 4 ie medium compression

filteredRowsback to summary
pack-priv byte[][] filteredRows
metadataback to summary
pack-priv PNGMetadata metadata
numBandsback to summary
pack-priv int numBands
periodXback to summary
pack-priv int periodX
periodYback to summary
pack-priv int periodY
pixelsDoneback to summary
pack-priv int pixelsDone
prevRowback to summary
pack-priv byte[] prevRow
rowFilterback to summary
pack-priv RowFilter rowFilter
sampleSizeback to summary
pack-priv int[] sampleSize
scaleback to summary
pack-priv byte[][] scale
scale0back to summary
pack-priv byte[] scale0
scalehback to summary
pack-priv byte[][] scaleh
scalelback to summary
pack-priv byte[][] scalel
scalingBitDepthback to summary
pack-priv int scalingBitDepth
sourceBandsback to summary
pack-priv int[] sourceBands
sourceHeightback to summary
pack-priv int sourceHeight
sourceWidthback to summary
pack-priv int sourceWidth
sourceXOffsetback to summary
pack-priv int sourceXOffset
sourceYOffsetback to summary
pack-priv int sourceYOffset
streamback to summary
pack-priv ImageOutputStream stream
totalPixelsback to summary
pack-priv int totalPixels

Constructor Detail

PNGImageWriterback to summary
public PNGImageWriter(ImageWriterSpi originatingProvider)

Method Detail

chunkTypeback to summary
private static int chunkType(String typeString)
convertImageMetadataback to summary
public IIOMetadata convertImageMetadata(IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.convertImageMetadata.

Implements javax.imageio.ImageTranscoder.convertImageMetadata.

Doc from javax.imageio.ImageTranscoder.convertImageMetadata.

Returns an IIOMetadata object that may be used for encoding and optionally modified using its document interfaces or other interfaces specific to the writer plug-in that will be used for encoding.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the image metadata.

If the supplied ImageWriteParam contains optional setting values not understood by this writer or transcoder, they will be ignored.

Annotations
@Override
convertStreamMetadataback to summary
public IIOMetadata convertStreamMetadata(IIOMetadata inData, ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.convertStreamMetadata.

Implements javax.imageio.ImageTranscoder.convertStreamMetadata.

Doc from javax.imageio.ImageTranscoder.convertStreamMetadata.

Returns an IIOMetadata object that may be used for encoding and optionally modified using its document interfaces or other interfaces specific to the writer plug-in that will be used for encoding.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the stream metadata.

If the supplied ImageWriteParam contains optional setting values not understood by this writer or transcoder, they will be ignored.

Annotations
@Override
deflateback to summary
private byte[] deflate(byte[] b) throws IOException
encodePassback to summary
private void encodePass(ImageOutputStream os, RenderedImage image, int xOffset, int yOffset, int xSkip, int ySkip) throws IOException
equalsback to summary
private boolean equals(int[] s0, int[] s1)
getDefaultImageMetadataback to summary
public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType, ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.getDefaultImageMetadata.

Doc from javax.imageio.ImageWriter.getDefaultImageMetadata.

Returns an IIOMetadata object containing default values for encoding an image of the given type. The contents of the object may be manipulated using either the XML tree structure returned by the IIOMetadata.getAsTree method, an IIOMetadataController object, or via plug-in specific interfaces, and the resulting data supplied to one of the write methods that take a stream metadata parameter.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the image metadata.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

Annotations
@Override
getDefaultStreamMetadataback to summary
public IIOMetadata getDefaultStreamMetadata(ImageWriteParam param)

Implements abstract javax.imageio.ImageWriter.getDefaultStreamMetadata.

Doc from javax.imageio.ImageWriter.getDefaultStreamMetadata.

Returns an IIOMetadata object containing default values for encoding a stream of images. The contents of the object may be manipulated using either the XML tree structure returned by the IIOMetadata.getAsTree method, an IIOMetadataController object, or via plug-in specific interfaces, and the resulting data supplied to one of the write methods that take a stream metadata parameter.

An optional ImageWriteParam may be supplied for cases where it may affect the structure of the stream metadata.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

Writers that do not make use of stream metadata (e.g., writers for single-image formats) should return null.

Annotations
@Override
getDefaultWriteParamback to summary
public ImageWriteParam getDefaultWriteParam()

Overrides javax.imageio.ImageWriter.getDefaultWriteParam.

Doc from javax.imageio.ImageWriter.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. This is useful as a starting point for tweaking just a few parameters and otherwise leaving the default settings alone.

The default implementation constructs and returns a new ImageWriteParam object that does not allow tiling, progressive encoding, or compression, and that will be localized for the current Locale (i.e., what you would get by calling new ImageWriteParam(getLocale()).

Individual plug-ins may return an instance of ImageWriteParam with additional optional features enabled, or they may return an instance of a plug-in specific subclass of ImageWriteParam.

Annotations
@Override
initializeScaleTablesback to summary
private void initializeScaleTables(int[] sampleSize)
setOutputback to summary
public void setOutput(Object output)

Overrides javax.imageio.ImageWriter.setOutput.

Doc from javax.imageio.ImageWriter.setOutput.

Sets the destination to the given ImageOutputStream or other Object. The destination is assumed to be ready to accept data, and will not be closed at the end of each write. This allows distributed imaging applications to transmit a series of images over a single network connection. If output is null, any currently set output will be removed.

If output is an ImageOutputStream, calls to the write, writeToSequence, and prepareWriteEmpty/endWriteEmpty methods will preserve the existing contents of the stream. Other write methods, such as writeInsert, replaceStreamMetadata, replaceImageMetadata, replacePixels, prepareInsertEmpty/endInsertEmpty, and endWriteSequence, require the full contents of the stream to be readable and writable, and may alter any portion of the stream.

Use of a general Object other than an ImageOutputStream is intended for writers that interact directly with an output device or imaging protocol. The set of legal classes is advertised by the writer's service provider's getOutputTypes method; most writers will return a single-element array containing only ImageOutputStream.class to indicate that they accept only an ImageOutputStream.

The default implementation sets the output instance variable to the value of output after checking output against the set of classes advertised by the originating provider, if there is one.

Annotations
@Override
writeback to summary
public void write(IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param) throws IIOException

Implements abstract javax.imageio.ImageWriter.write.

Doc from javax.imageio.ImageWriter.write.

Appends a complete image stream containing a single image and associated stream and image metadata and thumbnails to the output. Any necessary header information is included. If the output is an ImageOutputStream, its existing contents prior to the current seek position are not affected, and need not be readable or writable.

The output must have been set beforehand using the setOutput method.

Stream metadata may optionally be supplied; if it is null, default stream metadata will be used.

If canWriteRasters returns true, the IIOImage may contain a Raster source. Otherwise, it must contain a RenderedImage source.

The supplied thumbnails will be resized if needed, and any thumbnails in excess of the supported number will be ignored. If the format requires additional thumbnails that are not provided, the writer should generate them internally.

An ImageWriteParam may optionally be supplied to control the writing process. If param is null, a default write param will be used.

If the supplied ImageWriteParam contains optional setting values not supported by this writer (e.g. progressive encoding or any format-specific settings), they will be ignored.

Annotations
@Override
write_bKGDback to summary
private void write_bKGD() throws IOException
write_cHRMback to summary
private void write_cHRM() throws IOException
write_gAMAback to summary
private void write_gAMA() throws IOException
write_hISTback to summary
private void write_hIST() throws IOException, IIOException
write_iCCPback to summary
private void write_iCCP() throws IOException
write_IDATback to summary
private void write_IDAT(RenderedImage image, int deflaterLevel) throws IOException
write_IHDRback to summary
private void write_IHDR() throws IOException
write_iTXtback to summary
private void write_iTXt() throws IOException
write_magicback to summary
private void write_magic() throws IOException
write_pHYsback to summary
private void write_pHYs() throws IOException
write_PLTEback to summary
private void write_PLTE() throws IOException
write_sBITback to summary
private void write_sBIT() throws IOException
write_sPLTback to summary
private void write_sPLT() throws IOException
write_sRGBback to summary
private void write_sRGB() throws IOException
write_tEXtback to summary
private void write_tEXt() throws IOException
write_tIMEback to summary
private void write_tIME() throws IOException
write_tRNSback to summary
private void write_tRNS() throws IOException, IIOException
write_zTXtback to summary
private void write_zTXt() throws IOException
writeIENDback to summary
private void writeIEND() throws IOException
writeUnknownChunksback to summary
private void writeUnknownChunks() throws IOException