2018-06-11 22:41:11 +02:00
|
|
|
package ar.com.hjg.pngj.chunks;
|
|
|
|
|
|
|
|
import ar.com.hjg.pngj.ImageInfo;
|
|
|
|
import ar.com.hjg.pngj.PngHelperInternal;
|
|
|
|
import ar.com.hjg.pngj.PngjException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fdAT chunk. For APGN, not PGN standard
|
|
|
|
* <p>
|
2018-09-22 11:17:30 +02:00
|
|
|
* see
|
|
|
|
* https://wiki.mozilla.org/APNG_Specification#.60fdAT.60:_The_Frame_Data_Chunk
|
2018-06-11 22:41:11 +02:00
|
|
|
* <p>
|
2018-09-22 11:17:30 +02:00
|
|
|
* This implementation does not support buffering, this should be not managed
|
|
|
|
* similar to a IDAT chunk
|
|
|
|
*
|
2018-06-11 22:41:11 +02:00
|
|
|
*/
|
|
|
|
public class PngChunkFDAT extends PngChunkMultiple {
|
2018-09-22 11:17:30 +02:00
|
|
|
public final static String ID = "fdAT";
|
|
|
|
private int seqNum;
|
|
|
|
private byte[] buffer; // normally not allocated - if so, it's the raw data, so it includes the 4bytes seqNum
|
|
|
|
int datalen; // length of idat data, excluding seqNUm (= chunk.len-4)
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public PngChunkFDAT(final ImageInfo info) {
|
|
|
|
super(PngChunkFDAT.ID, info);
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
@Override
|
|
|
|
public ChunkOrderingConstraint getOrderingConstraint() {
|
|
|
|
return ChunkOrderingConstraint.AFTER_IDAT;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
@Override
|
|
|
|
public ChunkRaw createRawChunk() {
|
|
|
|
if (buffer == null)
|
|
|
|
throw new PngjException("not buffered");
|
|
|
|
final ChunkRaw c = createEmptyChunk(datalen + 4, false);
|
|
|
|
c.data = buffer; // shallow copy!
|
|
|
|
return c;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
@Override
|
|
|
|
public void parseFromRaw(final ChunkRaw chunk) {
|
|
|
|
seqNum = PngHelperInternal.readInt4fromBytes(chunk.data, 0);
|
|
|
|
datalen = chunk.len - 4;
|
|
|
|
buffer = chunk.data;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public int getSeqNum() {
|
|
|
|
return seqNum;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public void setSeqNum(final int seqNum) {
|
|
|
|
this.seqNum = seqNum;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public byte[] getBuffer() {
|
|
|
|
return buffer;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public void setBuffer(final byte[] buffer) {
|
|
|
|
this.buffer = buffer;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public int getDatalen() {
|
|
|
|
return datalen;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public void setDatalen(final int datalen) {
|
|
|
|
this.datalen = datalen;
|
|
|
|
}
|
2018-06-11 22:41:11 +02:00
|
|
|
|
|
|
|
}
|