Top Fields Constructors Methods
org.eclipse.swt.internal.image

public final Class PNGFileFormat

extends FileFormat
Class Inheritance
Imports
java.io.*, java.util.zip.*, org.eclipse.swt.*, org.eclipse.swt.graphics.*

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv byte[]
pack-priv byte[]
pack-priv byte
pack-priv byte
pack-priv PngIhdrChunk
pack-priv ImageData
pack-priv PngPlteChunk
pack-priv static final int
pack-priv static final int
Inherited from org.eclipse.swt.internal.image.FileFormat:
compressionFORMAT_PACKAGEFORMAT_SUFFIXFORMATSinputStreamloaderoutputStream

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
compress16BitDepthTo8BitDepth(byte[] source, int sourceOffset, byte[] destination, int destinationOffset, int numberOfValues)

SWT does not support 16-bit depth color formats.

pack-priv static int
compress16BitDepthTo8BitDepth(int value)

SWT does not support 16-bit depth color formats.

pack-priv void
filterRow(byte[] row, byte[] previousRow, int filterType)

PNG supports four filtering types.

pack-priv void
fireInterlacedFrameEvent(int frameCount)

Fire an event to let listeners know that an interlaced frame has been loaded.

pack-priv int
getAlignedBytesPerRow()

Answer the number of bytes in a word-aligned row of pixel data.

pack-priv int
getBytesPerPixel()

Answer the number of bytes needed to represent a pixel.

pack-priv int
getBytesPerRow()

Answer the number of bytes in each row of the image data.

pack-priv int
getBytesPerRow(int rowWidthInPixels)

Answer the number of bytes in a row of the given pixel width.

pack-priv boolean
isFileFormat(LEDataInputStream stream)

Implements abstract org.eclipse.swt.internal.image.FileFormat.isFileFormat.

Return whether or not the specified input stream represents a supported file format.
pack-priv ImageData[]
loadFromByteStream()

Implements abstract org.eclipse.swt.internal.image.FileFormat.loadFromByteStream.

Load the PNG image from the byte stream.
pack-priv void
readInterlacedImage(InputStream inputStream)

Read the pixel data for an interlaced image from the data stream.

pack-priv void
readInterlaceFrame(InputStream inputStream, int rowInterval, int columnInterval, int startRow, int startColumn, int frameCount)

1.

pack-priv void
readNextChunk(PngChunkReader chunkReader)

Read and handle the next chunk of data from the PNG file.

pack-priv void
readNonInterlacedImage(InputStream inputStream)

Read the pixel data for a non-interlaced image from the data stream.

pack-priv void
readPixelData(PngIdatChunk chunk, PngChunkReader chunkReader)

Read the image data from the data stream.

pack-priv void
readSignature()

Skip over signature data.

pack-priv void
setImageDataValues(byte[] data, ImageData imageData)

PNG supports some color types and bit depths that are unsupported by SWT.

pack-priv void
setPixelData(byte[] data, ImageData imageData)

SWT does not support greyscale as a color type.

pack-priv void
pack-priv byte[]
validateBitDepth(byte[] data)

SWT does not support 16-bit depths.

Inherited from org.eclipse.swt.internal.image.FileFormat:
getFileFormatloadloadFromStreamsaveunloadIntoStream

Field Detail

adlerback to summary
pack-priv int adler
alphaPaletteback to summary
pack-priv byte[] alphaPalette
databack to summary
pack-priv byte[] data
headerByte1back to summary
pack-priv byte headerByte1
headerByte2back to summary
pack-priv byte headerByte2
headerChunkback to summary
pack-priv PngIhdrChunk headerChunk
imageDataback to summary
pack-priv ImageData imageData
paletteChunkback to summary
pack-priv PngPlteChunk paletteChunk
PRIMEback to summary
pack-priv static final int PRIME
SIGNATURE_LENGTHback to summary
pack-priv static final int SIGNATURE_LENGTH

Constructor Detail

PNGFileFormatback to summary
public PNGFileFormat()

Method Detail

compress16BitDepthTo8BitDepthback to summary
pack-priv static void compress16BitDepthTo8BitDepth(byte[] source, int sourceOffset, byte[] destination, int destinationOffset, int numberOfValues)

SWT does not support 16-bit depth color formats. Convert the 16-bit data to 8-bit data. The correct way to do this is to multiply each 16 bit value by the value: (2^8 - 1) / (2^16 - 1). The fast way to do this is just to drop the low byte of the 16-bit value.

compress16BitDepthTo8BitDepthback to summary
pack-priv static int compress16BitDepthTo8BitDepth(int value)

SWT does not support 16-bit depth color formats. Convert the 16-bit data to 8-bit data. The correct way to do this is to multiply each 16 bit value by the value: (2^8 - 1) / (2^16 - 1). The fast way to do this is just to drop the low byte of the 16-bit value.

filterRowback to summary
pack-priv void filterRow(byte[] row, byte[] previousRow, int filterType)

PNG supports four filtering types. These types are applied per row of image data. This method unfilters the given row based on the filterType.

fireInterlacedFrameEventback to summary
pack-priv void fireInterlacedFrameEvent(int frameCount)

Fire an event to let listeners know that an interlaced frame has been loaded. finalFrame should be true if the image has finished loading, false if there are more frames to come.

getAlignedBytesPerRowback to summary
pack-priv int getAlignedBytesPerRow()

Answer the number of bytes in a word-aligned row of pixel data.

getBytesPerPixelback to summary
pack-priv int getBytesPerPixel()

Answer the number of bytes needed to represent a pixel. This value depends on the image's color type and bit depth. Note that this method rounds up if an image's pixel size isn't byte-aligned.

getBytesPerRowback to summary
pack-priv int getBytesPerRow()

Answer the number of bytes in each row of the image data. Each PNG row is byte-aligned, so images with bit depths less than a byte may have unused bits at the end of each row. The value of these bits is undefined.

getBytesPerRowback to summary
pack-priv int getBytesPerRow(int rowWidthInPixels)

Answer the number of bytes in a row of the given pixel width. Each row is byte-aligned, so images with bit depths less than a byte may have unused bits at the end of each row. The value of these bits is undefined.

isFileFormatback to summary
pack-priv boolean isFileFormat(LEDataInputStream stream)

Implements abstract org.eclipse.swt.internal.image.FileFormat.isFileFormat.

Doc from org.eclipse.swt.internal.image.FileFormat.isFileFormat.

Return whether or not the specified input stream represents a supported file format.

Annotations
@Override
loadFromByteStreamback to summary
pack-priv ImageData[] loadFromByteStream()

Implements abstract org.eclipse.swt.internal.image.FileFormat.loadFromByteStream.

Load the PNG image from the byte stream.

Annotations
@Override
readInterlacedImageback to summary
pack-priv void readInterlacedImage(InputStream inputStream) throws IOException

Read the pixel data for an interlaced image from the data stream.

readInterlaceFrameback to summary
pack-priv void readInterlaceFrame(InputStream inputStream, int rowInterval, int columnInterval, int startRow, int startColumn, int frameCount) throws IOException

1. Read one of the seven frames of interlaced data. 2. Update the imageData. 3. Notify the image loader's listeners of the frame load.

readNextChunkback to summary
pack-priv void readNextChunk(PngChunkReader chunkReader) throws IOException

Read and handle the next chunk of data from the PNG file.

readNonInterlacedImageback to summary
pack-priv void readNonInterlacedImage(InputStream inputStream) throws IOException

Read the pixel data for a non-interlaced image from the data stream. Update the imageData to reflect the new data.

readPixelDataback to summary
pack-priv void readPixelData(PngIdatChunk chunk, PngChunkReader chunkReader) throws IOException

Read the image data from the data stream. This must handle decoding the data, filtering, and interlacing.

readSignatureback to summary
pack-priv void readSignature() throws IOException

Skip over signature data. This has already been verified in isFileFormat().

setImageDataValuesback to summary
pack-priv void setImageDataValues(byte[] data, ImageData imageData)

PNG supports some color types and bit depths that are unsupported by SWT. If the image uses an unsupported color type (either of the gray scale types) or bit depth (16), convert the data to an SWT-supported format. Then assign the data into the ImageData given.

setPixelDataback to summary
pack-priv void setPixelData(byte[] data, ImageData imageData)

SWT does not support greyscale as a color type. For plain grayscale, we create a palette. For Grayscale with Alpha, however, we need to convert the pixels to use RGB values.

Note

This method assumes that the bit depth of the data has already been restricted to 8 or less.

unloadIntoByteStreamback to summary
pack-priv void unloadIntoByteStream(ImageLoader loader)

Implements abstract org.eclipse.swt.internal.image.FileFormat.unloadIntoByteStream.

Annotations
@Override
validateBitDepthback to summary
pack-priv byte[] validateBitDepth(byte[] data)

SWT does not support 16-bit depths. If this image uses 16-bit depths, convert the data to an 8-bit depth.