ar.com.hjg.pngj.chunks
Class ChunkRaw

java.lang.Object
  extended by ar.com.hjg.pngj.chunks.ChunkRaw

public class ChunkRaw
extends java.lang.Object

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
 byte[] data
          The data bytes appropriate to the chunk type, if any.
 byte[] idbytes
          A 4-byte chunk type code. uppercase and lowercase ASCII letters
 int len
          The length counts only the data field, not itself, the chunk type code, or the CRC.
 
Constructor Summary
ChunkRaw(int len, byte[] idbytes, boolean alloc)
           
 
Method Summary
 int readChunkData(java.io.InputStream is)
          position before: just after chunk id. positon after: after crc Data should be already allocated.
 java.lang.String toString()
           
 void writeChunk(java.io.OutputStream os)
          Computes the CRC and writes to the stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

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


idbytes

public final byte[] idbytes
A 4-byte chunk type code. uppercase and lowercase ASCII letters


len

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

ChunkRaw

public ChunkRaw(int len,
                byte[] idbytes,
                boolean alloc)
Parameters:
len - : data len
idbytes - : chunk type (deep copied)
alloc - : it true, the data array will be allocced
Method Detail

readChunkData

public int readChunkData(java.io.InputStream is)
position before: just after chunk id. positon after: after crc Data should be already allocated. Checks CRC Return number of byte read.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeChunk

public void writeChunk(java.io.OutputStream os)
Computes the CRC and writes to the stream. If error, a PngjOutputException is thrown