Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.internal.image
Class PNGFileFormat  view PNGFileFormat download PNGFileFormat.java

java.lang.Object
  extended byorg.eclipse.swt.internal.image.FileFormat
      extended byorg.eclipse.swt.internal.image.PNGFileFormat

final class PNGFileFormat
extends FileFormat


Field Summary
(package private)  byte[] alphaPalette
           
(package private)  byte[] data
           
(package private)  PngDecodingDataStream decodingStream
           
(package private)  PngIhdrChunk headerChunk
           
(package private)  org.eclipse.swt.graphics.ImageData imageData
           
(package private)  PngPlteChunk paletteChunk
           
(package private) static int SIGNATURE_LENGTH
           
(package private)  PngTrnsChunk trnsChunk
           
 
Fields inherited from class org.eclipse.swt.internal.image.FileFormat
compression, FORMAT_PACKAGE, FORMAT_SUFFIX, FORMATS, inputStream, loader, outputStream
 
Constructor Summary
(package private) PNGFileFormat()
           
 
Method Summary
(package private) static void compress16BitDepthTo8BitDepth(byte[] source, int sourceOffset, byte[] destination, int destinationOffset, int numberOfValues)
          SWT does not support 16-bit depth color formats.
(package private) static int compress16BitDepthTo8BitDepth(int value)
          SWT does not support 16-bit depth color formats.
(package private)  void filterRow(byte[] row, byte[] previousRow, int filterType)
          PNG supports four filtering types.
(package private)  void fireInterlacedFrameEvent(int frameCount)
          Fire an event to let listeners know that an interlaced frame has been loaded.
(package private)  int getAlignedBytesPerRow()
          Answer the number of bytes in a word-aligned row of pixel data.
(package private)  int getBytesPerPixel()
          Answer the number of bytes needed to represent a pixel.
(package private)  int getBytesPerRow()
          Answer the number of bytes in each row of the image data.
(package private)  int getBytesPerRow(int rowWidthInPixels)
          Answer the number of bytes in a row of the given pixel width.
(package private)  boolean isFileFormat(LEDataInputStream stream)
          Return whether or not the specified input stream represents a supported file format.
(package private)  org.eclipse.swt.graphics.ImageData[] loadFromByteStream()
          Load the PNG image from the byte stream.
(package private)  void readInterlacedImage()
          Read the pixel data for an interlaced image from the data stream.
(package private)  void readInterlaceFrame(int rowInterval, int columnInterval, int startRow, int startColumn, int frameCount)
          1.
(package private)  void readNextChunk(PngChunkReader chunkReader)
          Read and handle the next chunk of data from the PNG file.
(package private)  void readNonInterlacedImage()
          Read the pixel data for a non-interlaced image from the data stream.
(package private)  void readPixelData(PngIdatChunk chunk, PngChunkReader chunkReader)
          Read the image data from the data stream.
(package private)  void readSignature()
          Skip over signature data.
(package private)  void setImageDataValues(byte[] data, org.eclipse.swt.graphics.ImageData imageData)
          PNG supports some color types and bit depths that are unsupported by SWT.
(package private)  void setPixelData(byte[] data, org.eclipse.swt.graphics.ImageData imageData)
          SWT does not support greyscale as a color type.
(package private)  void unloadIntoByteStream(org.eclipse.swt.graphics.ImageData p1)
           
(package private)  byte[] validateBitDepth(byte[] data)
          SWT does not support 16-bit depths.
 
Methods inherited from class org.eclipse.swt.internal.image.FileFormat
bitInvertData, load, loadFromStream, save, unloadIntoStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIGNATURE_LENGTH

static final int SIGNATURE_LENGTH
See Also:
Constant Field Values

decodingStream

PngDecodingDataStream decodingStream

headerChunk

PngIhdrChunk headerChunk

paletteChunk

PngPlteChunk paletteChunk

trnsChunk

PngTrnsChunk trnsChunk

imageData

org.eclipse.swt.graphics.ImageData imageData

data

byte[] data

alphaPalette

byte[] alphaPalette
Constructor Detail

PNGFileFormat

PNGFileFormat()
Method Detail

readSignature

void readSignature()
             throws java.io.IOException
Skip over signature data. This has already been verified in isPNGFile().


loadFromByteStream

org.eclipse.swt.graphics.ImageData[] loadFromByteStream()
Load the PNG image from the byte stream.

Specified by:
loadFromByteStream in class FileFormat

readNextChunk

void readNextChunk(PngChunkReader chunkReader)
Read and handle the next chunk of data from the PNG file.


unloadIntoByteStream

void unloadIntoByteStream(org.eclipse.swt.graphics.ImageData p1)
Specified by:
unloadIntoByteStream in class FileFormat

isFileFormat

boolean isFileFormat(LEDataInputStream stream)
Description copied from class: FileFormat
Return whether or not the specified input stream represents a supported file format.

Specified by:
isFileFormat in class FileFormat

validateBitDepth

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.


setPixelData

void setPixelData(byte[] data,
                  org.eclipse.swt.graphics.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.


setImageDataValues

void setImageDataValues(byte[] data,
                        org.eclipse.swt.graphics.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.


readPixelData

void readPixelData(PngIdatChunk chunk,
                   PngChunkReader chunkReader)
Read the image data from the data stream. This must handle decoding the data, filtering, and interlacing.


getAlignedBytesPerRow

int getAlignedBytesPerRow()
Answer the number of bytes in a word-aligned row of pixel data.


getBytesPerRow

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.


getBytesPerPixel

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.


getBytesPerRow

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.


readInterlaceFrame

void readInterlaceFrame(int rowInterval,
                        int columnInterval,
                        int startRow,
                        int startColumn,
                        int frameCount)
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.


readInterlacedImage

void readInterlacedImage()
Read the pixel data for an interlaced image from the data stream.


fireInterlacedFrameEvent

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.


readNonInterlacedImage

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


compress16BitDepthTo8BitDepth

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.


compress16BitDepthTo8BitDepth

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.


filterRow

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.