/// <summary> /// Reads (and processes ... up to a point) chunks after last IDAT. /// </summary> /// private void ReadLastChunks() { CurrentChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT; // PngHelper.logdebug("idat ended? " + iIdatCstream.isEnded()); if (!iIdatCstream.IsEnded()) { iIdatCstream.ForceChunkEnd(); } var clen = iIdatCstream.GetLenLastChunk(); var chunkid = iIdatCstream.GetIdLastChunk(); var endfound = false; var first = true; while (!endfound) { var 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); }
public void ReadLastChunks() { CurrentChunkGroup = 5; if (!iIdatCstream.IsEnded()) { iIdatCstream.ForceChunkEnd(); } int num = iIdatCstream.GetLenLastChunk(); byte[] idLastChunk = iIdatCstream.GetIdLastChunk(); bool flag = false; bool flag2 = true; bool flag3 = false; while (!flag) { flag3 = false; if (!flag2) { num = PngHelperInternal.ReadInt4(inputStream); offset += 4L; if (num < 0) { throw new PngjInputException("bad len " + num.ToString()); } PngHelperInternal.ReadBytes(inputStream, idLastChunk, 0, 4); offset += 4L; } flag2 = false; if (PngCsUtils.arraysEqual4(idLastChunk, ChunkHelper.b_IDAT)) { flag3 = true; } else if (PngCsUtils.arraysEqual4(idLastChunk, ChunkHelper.b_IEND)) { CurrentChunkGroup = 6; flag = true; } ReadChunk(idLastChunk, num, flag3); } if (!flag) { throw new PngjInputException("end chunk not found - offset=" + offset.ToString()); } }