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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.eclipse.swt.internal.image.PngChunk
      extended byorg.eclipse.swt.internal.image.PngIhdrChunk

class PngIhdrChunk
extends PngChunk


Field Summary
(package private) static int BIT_DEPTH_OFFSET
           
(package private) static int CHUNK_IDAT
           
(package private) static int CHUNK_IEND
           
(package private) static int CHUNK_IHDR
           
(package private) static int CHUNK_PLTE
           
(package private) static int CHUNK_tRNS
           
(package private) static int CHUNK_UNKNOWN
           
(package private) static int COLOR_TYPE_GRAYSCALE
           
(package private) static int COLOR_TYPE_GRAYSCALE_WITH_ALPHA
           
(package private) static int COLOR_TYPE_OFFSET
           
(package private) static int COLOR_TYPE_PALETTE
           
(package private) static int COLOR_TYPE_RGB
           
(package private) static int COLOR_TYPE_RGB_WITH_ALPHA
           
(package private) static int COMPRESSION_METHOD_OFFSET
           
(package private) static int[] CRC_TABLE
           
(package private) static int DATA_OFFSET
           
(package private) static int EXPECTED_DATA_LENGTH
           
(package private) static int FILTER_AVERAGE
           
(package private) static int FILTER_METHOD_OFFSET
           
(package private) static int FILTER_NONE
           
(package private) static int FILTER_PAETH
           
(package private) static int FILTER_SUB
           
(package private) static int FILTER_UP
           
(package private) static int HEIGHT_DATA_OFFSET
           
(package private) static int INTERLACE_METHOD_ADAM7
           
(package private) static int INTERLACE_METHOD_NONE
           
(package private) static int INTERLACE_METHOD_OFFSET
           
(package private) static int LENGTH_FIELD_LENGTH
           
(package private) static int LENGTH_OFFSET
           
(package private) static int MIN_LENGTH
           
(package private)  byte[] reference
           
(package private) static int TYPE_FIELD_LENGTH
           
(package private) static byte[] TYPE_IDAT
           
(package private) static byte[] TYPE_IEND
           
(package private) static byte[] TYPE_IHDR
           
(package private) static int TYPE_OFFSET
           
(package private) static byte[] TYPE_PLTE
           
(package private) static byte[] TYPE_tRNS
           
(package private) static byte[] ValidBitDepths
           
(package private) static byte[] ValidColorTypes
           
(package private) static int WIDTH_DATA_OFFSET
           
 
Constructor Summary
(package private) PngIhdrChunk(byte[] reference)
          Construct a PNGChunk using the reference bytes given.
 
Method Summary
(package private)  boolean checkCRC()
          Compute the CRC value for the chunk's data.
(package private)  int computeCRC()
          Answer the CRC value of chunk's data.
(package private)  void contributeToString(java.lang.StringBuffer buffer)
          Provided so that subclasses can override and add data to the toString() call.
(package private)  org.eclipse.swt.graphics.PaletteData createGrayscalePalette()
           
(package private)  byte getBitDepth()
          Get the image's bit depth.
(package private)  int getBitsPerPixel()
          Answer the pixel size in bits based on the color type and bit depth.
(package private)  boolean getCanHavePalette()
           
(package private)  int getChunkType()
           
(package private)  byte getColorType()
          Get the image's color type.
(package private)  java.lang.String getColorTypeString()
           
(package private)  byte getCompressionMethod()
          Get the image's compression method.
(package private)  int getCRC()
          Get the CRC value for the chunk's data.
(package private)  byte[] getData()
          Get the chunk's data.
(package private)  int getFilterByteOffset()
           
(package private)  byte getFilterMethod()
          Get the image's filter method.
(package private)  java.lang.String getFilterMethodString()
           
(package private)  int getHeight()
          Get the image's height in pixels.
(package private)  int getInt32(int offset)
          Get the 32-bit integer from the reference byte array at the given offset.
(package private)  byte getInterlaceMethod()
          Get the image's interlace method.
(package private)  java.lang.String getInterlaceMethodString()
           
(package private)  int getLength()
          Get the length of the data component of this chunk.
(package private)  boolean getMustHavePalette()
           
(package private)  org.eclipse.swt.graphics.PaletteData getPaletteData()
           
(package private)  byte[] getReference()
          Get the PngChunk's reference byteArray;
(package private)  int getSize()
          Get the chunk's total size including the length, type, and crc fields.
(package private)  int getSwtBitsPerPixel()
          Answer the pixel size in bits based on the color type and bit depth.
(package private)  byte[] getTypeBytes()
          Get the chunk type.
(package private)  int getWidth()
          Get the image's width in pixels.
(package private)  boolean isCritical()
           
(package private) static PngChunk readNextFromStream(LEDataInputStream stream)
          Read the next PNG chunk from the input stream given.
(package private)  void setBitDepth(byte value)
          Set the image's bit depth.
(package private)  void setColorType(byte value)
          Set the image's color type.
(package private)  void setCompressionMethod(byte value)
          Set the image's compression method.
(package private)  void setCRC(int value)
          Set the CRC value for the chunk's data.
(package private)  void setData(byte[] data)
          Set the chunk's data.
(package private)  void setFilterMethod(byte value)
          Set the image's filter method.
(package private)  void setHeight(int value)
          Set the image's height in pixels.
(package private)  void setInt32(int offset, int value)
          Set the 32-bit integer in the reference byte array at the given offset.
(package private)  void setInterlaceMethod(byte value)
          Set the image's interlace method.
(package private)  void setLength(int value)
          Set the length of the data component of this chunk.
(package private)  void setReference(byte[] reference)
          Set the PngChunk's reference byteArray;
(package private)  void setType(byte[] value)
          Set the chunk type.
(package private)  void setWidth(int value)
          Set the image's width in pixels.
 java.lang.String toString()
          Convert this Object to a human-readable String.
(package private)  boolean typeMatchesArray(byte[] array)
           
(package private)  boolean usesDirectColor()
           
(package private)  void validate(PngFileReadState readState, PngIhdrChunk headerChunk)
          Answer whether the chunk is a valid IHDR chunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXPECTED_DATA_LENGTH

static final int EXPECTED_DATA_LENGTH
See Also:
Constant Field Values

WIDTH_DATA_OFFSET

static final int WIDTH_DATA_OFFSET
See Also:
Constant Field Values

HEIGHT_DATA_OFFSET

static final int HEIGHT_DATA_OFFSET
See Also:
Constant Field Values

BIT_DEPTH_OFFSET

static final int BIT_DEPTH_OFFSET
See Also:
Constant Field Values

COLOR_TYPE_OFFSET

static final int COLOR_TYPE_OFFSET
See Also:
Constant Field Values

COMPRESSION_METHOD_OFFSET

static final int COMPRESSION_METHOD_OFFSET
See Also:
Constant Field Values

FILTER_METHOD_OFFSET

static final int FILTER_METHOD_OFFSET
See Also:
Constant Field Values

INTERLACE_METHOD_OFFSET

static final int INTERLACE_METHOD_OFFSET
See Also:
Constant Field Values

COLOR_TYPE_GRAYSCALE

static final int COLOR_TYPE_GRAYSCALE
See Also:
Constant Field Values

COLOR_TYPE_RGB

static final int COLOR_TYPE_RGB
See Also:
Constant Field Values

COLOR_TYPE_PALETTE

static final int COLOR_TYPE_PALETTE
See Also:
Constant Field Values

COLOR_TYPE_GRAYSCALE_WITH_ALPHA

static final int COLOR_TYPE_GRAYSCALE_WITH_ALPHA
See Also:
Constant Field Values

COLOR_TYPE_RGB_WITH_ALPHA

static final int COLOR_TYPE_RGB_WITH_ALPHA
See Also:
Constant Field Values

INTERLACE_METHOD_NONE

static final int INTERLACE_METHOD_NONE
See Also:
Constant Field Values

INTERLACE_METHOD_ADAM7

static final int INTERLACE_METHOD_ADAM7
See Also:
Constant Field Values

FILTER_NONE

static final int FILTER_NONE
See Also:
Constant Field Values

FILTER_SUB

static final int FILTER_SUB
See Also:
Constant Field Values

FILTER_UP

static final int FILTER_UP
See Also:
Constant Field Values

FILTER_AVERAGE

static final int FILTER_AVERAGE
See Also:
Constant Field Values

FILTER_PAETH

static final int FILTER_PAETH
See Also:
Constant Field Values

ValidBitDepths

static final byte[] ValidBitDepths

ValidColorTypes

static final byte[] ValidColorTypes

reference

byte[] reference

LENGTH_OFFSET

static final int LENGTH_OFFSET
See Also:
Constant Field Values

TYPE_OFFSET

static final int TYPE_OFFSET
See Also:
Constant Field Values

DATA_OFFSET

static final int DATA_OFFSET
See Also:
Constant Field Values

TYPE_FIELD_LENGTH

static final int TYPE_FIELD_LENGTH
See Also:
Constant Field Values

LENGTH_FIELD_LENGTH

static final int LENGTH_FIELD_LENGTH
See Also:
Constant Field Values

MIN_LENGTH

static final int MIN_LENGTH
See Also:
Constant Field Values

CHUNK_UNKNOWN

static final int CHUNK_UNKNOWN
See Also:
Constant Field Values

CHUNK_IHDR

static final int CHUNK_IHDR
See Also:
Constant Field Values

CHUNK_PLTE

static final int CHUNK_PLTE
See Also:
Constant Field Values

CHUNK_IDAT

static final int CHUNK_IDAT
See Also:
Constant Field Values

CHUNK_IEND

static final int CHUNK_IEND
See Also:
Constant Field Values

CHUNK_tRNS

static final int CHUNK_tRNS
See Also:
Constant Field Values

TYPE_IHDR

static final byte[] TYPE_IHDR

TYPE_PLTE

static final byte[] TYPE_PLTE

TYPE_IDAT

static final byte[] TYPE_IDAT

TYPE_IEND

static final byte[] TYPE_IEND

TYPE_tRNS

static final byte[] TYPE_tRNS

CRC_TABLE

static final int[] CRC_TABLE
Constructor Detail

PngIhdrChunk

PngIhdrChunk(byte[] reference)
Construct a PNGChunk using the reference bytes given.

Method Detail

getWidth

int getWidth()
Get the image's width in pixels.


setWidth

void setWidth(int value)
Set the image's width in pixels.


getHeight

int getHeight()
Get the image's height in pixels.


setHeight

void setHeight(int value)
Set the image's height in pixels.


getBitDepth

byte getBitDepth()
Get the image's bit depth. This is limited to the values 1, 2, 4, 8, or 16.


setBitDepth

void setBitDepth(byte value)
Set the image's bit depth. This is limited to the values 1, 2, 4, 8, or 16.


getColorType

byte getColorType()
Get the image's color type. This is limited to the values: 0 - Grayscale image. 2 - RGB triple. 3 - Palette. 4 - Grayscale with Alpha channel. 6 - RGB with Alpha channel.


setColorType

void setColorType(byte value)
Set the image's color type. This is limited to the values: 0 - Grayscale image. 2 - RGB triple. 3 - Palette. 4 - Grayscale with Alpha channel. 6 - RGB with Alpha channel.


getCompressionMethod

byte getCompressionMethod()
Get the image's compression method. This value must be 0.


setCompressionMethod

void setCompressionMethod(byte value)
Set the image's compression method. This value must be 0.


getFilterMethod

byte getFilterMethod()
Get the image's filter method. This value must be 0.


setFilterMethod

void setFilterMethod(byte value)
Set the image's filter method. This value must be 0.


getInterlaceMethod

byte getInterlaceMethod()
Get the image's interlace method. This value is limited to: 0 - No interlacing used. 1 - Adam7 interlacing used.


setInterlaceMethod

void setInterlaceMethod(byte value)
Set the image's interlace method. This value is limited to: 0 - No interlacing used. 1 - Adam7 interlacing used.


validate

void validate(PngFileReadState readState,
              PngIhdrChunk headerChunk)
Answer whether the chunk is a valid IHDR chunk.

Overrides:
validate in class PngChunk

getColorTypeString

java.lang.String getColorTypeString()

getFilterMethodString

java.lang.String getFilterMethodString()

getInterlaceMethodString

java.lang.String getInterlaceMethodString()

contributeToString

void contributeToString(java.lang.StringBuffer buffer)
Description copied from class: PngChunk
Provided so that subclasses can override and add data to the toString() call.

Overrides:
contributeToString in class PngChunk

getMustHavePalette

boolean getMustHavePalette()

getCanHavePalette

boolean getCanHavePalette()

getBitsPerPixel

int getBitsPerPixel()
Answer the pixel size in bits based on the color type and bit depth.


getSwtBitsPerPixel

int getSwtBitsPerPixel()
Answer the pixel size in bits based on the color type and bit depth.


getFilterByteOffset

int getFilterByteOffset()

usesDirectColor

boolean usesDirectColor()

createGrayscalePalette

org.eclipse.swt.graphics.PaletteData createGrayscalePalette()

getPaletteData

org.eclipse.swt.graphics.PaletteData getPaletteData()

getReference

byte[] getReference()
Get the PngChunk's reference byteArray;


setReference

void setReference(byte[] reference)
Set the PngChunk's reference byteArray;


getInt32

int getInt32(int offset)
Get the 32-bit integer from the reference byte array at the given offset.


setInt32

void setInt32(int offset,
              int value)
Set the 32-bit integer in the reference byte array at the given offset.


getLength

int getLength()
Get the length of the data component of this chunk. This is not the length of the entire chunk.


setLength

void setLength(int value)
Set the length of the data component of this chunk. This is not the length of the entire chunk.


getTypeBytes

byte[] getTypeBytes()
Get the chunk type. This is a four byte value. Each byte should be an ASCII character. The first byte is upper case if the chunk is critical. The second byte is upper case if the chunk is publicly defined. The third byte must be upper case. The fourth byte is upper case if the chunk is unsafe to copy. Public chunk types are defined by the PNG Development Group.


setType

void setType(byte[] value)
Set the chunk type. This is a four byte value. Each byte should be an ASCII character. The first byte is upper case if the chunk is critical. The second byte is upper case if the chunk is publicly defined. The third byte must be upper case. The fourth byte is upper case if the chunk is unsafe to copy. Public chunk types are defined by the PNG Development Group.


getData

byte[] getData()
Get the chunk's data.


setData

void setData(byte[] data)
Set the chunk's data. This method has two side-effects. 1. It will set the length field to be the length of the data array given. 2. It will set the CRC field to the computed CRC value of the data array given.


getCRC

int getCRC()
Get the CRC value for the chunk's data. Ensure that the length field has a good value before making this call.


setCRC

void setCRC(int value)
Set the CRC value for the chunk's data. Ensure that the length field has a good value before making this call.


getSize

int getSize()
Get the chunk's total size including the length, type, and crc fields.


checkCRC

boolean checkCRC()
Compute the CRC value for the chunk's data. Answer whether this value matches the value stored in the chunk.


computeCRC

int computeCRC()
Answer the CRC value of chunk's data.


typeMatchesArray

boolean typeMatchesArray(byte[] array)

isCritical

boolean isCritical()

getChunkType

int getChunkType()

readNextFromStream

static PngChunk readNextFromStream(LEDataInputStream stream)
Read the next PNG chunk from the input stream given. If unable to read a chunk, return null.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).