Top Description Fields Constructors Methods
jogamp.opengl.util.pngj.chunks

public Class ChunkRaw

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .InputStream, .OutputStream, java.util.zip.CRC32, jogamp.opengl.util.pngj.PngHelperInternal, .PngjBadCrcException, .PngjOutputException

Raw (physical) chunk.

Short lived object, to be created while serialing/deserializing Do not reuse it for different chunks.
See http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html

Field Summary

Modifier and TypeField and Description
private int
crcval

A 4-byte CRC (Cyclic Redundancy Check) calculated on the preceding bytes in the chunk, including the chunk type code and chunk data fields, but not including the length field.

public byte[]
data

The data bytes appropriate to the chunk type, if any.

public final byte[]
idbytes

A 4-byte chunk type code.

public final int
len

The length counts only the data field, not itself, the chunk type code, or the CRC.

Constructor Summary

AccessConstructor and Description
public
ChunkRaw(final int
: data len
len
,
final byte[]
: chunk type (deep copied)
idbytes
,
final boolean
: it true, the data array will be allocced
alloc
)

Method Summary

Modifier and TypeMethod and Description
private void
private int
computeCrc()

this is called after setting data, before writing to os

pack-priv ByteArrayInputStream
public int
readChunkData(final InputStream is, final boolean checkCrc)

position before: just after chunk id. positon after: after crc Data should be already allocated.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
writeChunk(final OutputStream os)

Computes the CRC and writes to the stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

crcvalback to summary
private int crcval

A 4-byte CRC (Cyclic Redundancy Check) calculated on the preceding bytes in the chunk, including the chunk type code and chunk data fields, but not including the length field.

databack to summary
public byte[] data

The data bytes appropriate to the chunk type, if any. This field can be of zero length. Does not include crc

idbytesback to summary
public final byte[] idbytes

A 4-byte chunk type code. uppercase and lowercase ASCII letters

lenback to summary
public final int len

The length counts only the data field, not itself, the chunk type code, or the CRC. Zero is a valid length. Although encoders and decoders should treat the length as unsigned, its value must not exceed 231-1 bytes.

Constructor Detail

ChunkRawback to summary
public ChunkRaw(final int len, final byte[] idbytes, final boolean alloc)
Parameters
len:int

: data len

idbytes:byte[]

: chunk type (deep copied)

alloc:boolean

: it true, the data array will be allocced

Method Detail

allocDataback to summary
private void allocData()
computeCrcback to summary
private int computeCrc()

this is called after setting data, before writing to os

getAsByteStreamback to summary
pack-priv ByteArrayInputStream getAsByteStream()
readChunkDataback to summary
public int readChunkData(final InputStream is, final boolean checkCrc)

position before: just after chunk id. positon after: after crc Data should be already allocated. Checks CRC Return number of byte read.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
writeChunkback to summary
public void writeChunk(final OutputStream os)

Computes the CRC and writes to the stream. If error, a PngjOutputException is thrown