private void ReadLastChunks()
{
CurrentChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT;
// PngHelper.logdebug("idat ended? " + iIdatCstream.isEnded());
if (!iIdatCstream.IsEnded())
iIdatCstream.ForceChunkEnd();
int clen = iIdatCstream.GetLenLastChunk();
byte[] chunkid = iIdatCstream.GetIdLastChunk();
bool endfound = false;
bool first = true;
bool skip = false;
while (!endfound) {
skip = false;
if (!first) {
clen = PngHelperInternal.ReadInt4(inputStream);
offset += 4;
if (clen < 0)
throw new PngjInputException("bad len " + clen);
PngHelperInternal.ReadBytes(inputStream, chunkid, 0, 4);
offset += 4;
}
first = false;
if (PngCsUtils.arraysEqual4(chunkid, ChunkHelper.b_IDAT)) {
skip = true; // extra dummy (empty?) idat chunk, it can happen, ignore it
} else if (PngCsUtils.arraysEqual4(chunkid, ChunkHelper.b_IEND)) {
CurrentChunkGroup = ChunksList.CHUNK_GROUP_6_END;
endfound = true;
}
ReadChunk(chunkid, clen, skip);
}
if (!endfound)
throw new PngjInputException("end chunk not found - offset=" + offset);
// PngHelper.logdebug("end chunk found ok offset=" + offset);
}