public GetChunksList ( ) : Hjg.Pngcs.Chunks.ChunksList | ||
return | Hjg.Pngcs.Chunks.ChunksList |
/// <summary> /// copy chunks from reader - copy_mask : see ChunksToWrite.COPY_XXX /// If we are after idat, only considers those chunks after IDAT in PngReader /// TODO: this should be more customizable /// </summary> /// private void CopyChunks(PngReader reader, int copy_mask, bool onlyAfterIdat) { bool idatDone = CurrentChunkGroup >= ChunksList.CHUNK_GROUP_4_IDAT; if (onlyAfterIdat && reader.CurrentChunkGroup < ChunksList.CHUNK_GROUP_6_END) throw new PngjException("tried to copy last chunks but reader has not ended"); foreach (PngChunk chunk in reader.GetChunksList().GetChunks()) { int group = chunk.ChunkGroup; if (group < ChunksList.CHUNK_GROUP_4_IDAT && idatDone) continue; bool copy = false; if (chunk.Crit) { if (chunk.Id.Equals(ChunkHelper.PLTE, StringComparison.InvariantCultureIgnoreCase)) { if (ImgInfo.Indexed && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_PALETTE)) copy = true; if (!ImgInfo.Greyscale && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL)) copy = true; } } else { // ancillary bool text = chunk is PngChunkTextVar; bool safe = chunk.Safe; // notice that these if are not exclusive if (ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL)) copy = true; if (safe && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL_SAFE)) copy = true; if (chunk.Id.Equals(ChunkHelper.tRNS, StringComparison.InvariantCultureIgnoreCase) && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_TRANSPARENCY)) copy = true; if (chunk.Id.Equals(ChunkHelper.pHYs, StringComparison.InvariantCultureIgnoreCase) && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_PHYS)) copy = true; if (text && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_TEXTUAL)) copy = true; if (ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALMOSTALL) && !(ChunkHelper.IsUnknown(chunk) || text || chunk.Id.Equals(ChunkHelper.hIST, StringComparison.InvariantCultureIgnoreCase) || chunk.Id.Equals(ChunkHelper.tIME, StringComparison.InvariantCultureIgnoreCase))) copy = true; if (chunk is PngChunkSkipped) copy = false; } if (copy) chunksList.Queue(PngChunk.CloneChunk(chunk, ImgInfo)); } }
private void CopyChunks( PngReader reader, int copy_mask, bool onlyAfterIdat ) { bool idatDone = CurrentChunkGroup >= ChunksList.CHUNK_GROUP_4_IDAT; if ( onlyAfterIdat && reader.CurrentChunkGroup < ChunksList.CHUNK_GROUP_6_END ) throw new PngjException ( "tried to copy last chunks but reader has not ended" ); foreach ( PngChunk chunk in reader.GetChunksList ().GetChunks () ) { int group = chunk.ChunkGroup; if ( group < ChunksList.CHUNK_GROUP_4_IDAT && idatDone ) continue; bool copy = false; if ( chunk.Crit ) { if ( chunk.Id.Equals ( ChunkHelper.PLTE ) ) { if ( ImgInfo.Indexed && ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_PALETTE ) ) copy = true; if ( !ImgInfo.Greyscale && ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_ALL ) ) copy = true; } } else { bool text = ( chunk is PngChunkTextVar ); bool safe = chunk.Safe; if ( ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_ALL ) ) copy = true; if ( safe && ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_ALL_SAFE ) ) copy = true; if ( chunk.Id.Equals ( ChunkHelper.tRNS ) && ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_TRANSPARENCY ) ) copy = true; if ( chunk.Id.Equals ( ChunkHelper.pHYs ) && ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_PHYS ) ) copy = true; if ( text && ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_TEXTUAL ) ) copy = true; if ( ChunkHelper.maskMatch ( copy_mask, ChunkCopyBehaviour.COPY_ALMOSTALL ) && !( ChunkHelper.IsUnknown ( chunk ) || text || chunk.Id.Equals ( ChunkHelper.hIST ) || chunk.Id .Equals ( ChunkHelper.tIME ) ) ) copy = true; if ( chunk is PngChunkSkipped ) copy = false; } if ( copy ) { chunksList.Queue ( PngChunk.CloneChunk ( chunk, ImgInfo ) ); } } }
/// <summary> /// copy chunks from reader - copy_mask : see ChunksToWrite.COPY_XXX /// If we are after idat, only considers those chunks after IDAT in PngReader /// TODO: this should be more customizable /// </summary> /// private void CopyChunks(PngReader reader, int copy_mask, bool onlyAfterIdat) { if (reader is null) { throw new ArgumentNullException(nameof(reader)); } var idatDone = CurrentChunkGroup >= ChunksList.CHUNK_GROUP_4_IDAT; if (onlyAfterIdat && reader.CurrentChunkGroup < ChunksList.CHUNK_GROUP_6_END) { throw new PngjException("tried to copy last chunks but reader has not ended"); } foreach (var chunk in reader.GetChunksList().Chunks) { var group = chunk.ChunkGroup; if (group < ChunksList.CHUNK_GROUP_4_IDAT && idatDone) { continue; } var copy = false; if (chunk.Crit) { if (chunk.Id.Equals(ChunkHelper.PLTE, StringComparison.Ordinal)) { if (ImgInfo.Indexed && ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_PALETTE)) { copy = true; } if (!ImgInfo.Greyscale && ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL)) { copy = true; } } } else { // ancillary var text = (chunk is AbstractPngChunkTextVar); var safe = chunk.Safe; // notice that these if are not exclusive if (ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL)) { copy = true; } if (safe && ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL_SAFE)) { copy = true; } if (chunk.Id.Equals(ChunkHelper.tRNS, StringComparison.Ordinal) && ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_TRANSPARENCY)) { copy = true; } if (chunk.Id.Equals(ChunkHelper.pHYs, StringComparison.Ordinal) && ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_PHYS)) { copy = true; } if (text && ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_TEXTUAL)) { copy = true; } if (((ChunkHelper.MaskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALMOSTALL) && !ChunkHelper.IsUnknown(chunk)) || text || chunk.Id.Equals(ChunkHelper.hIST, StringComparison.Ordinal) || chunk.Id.Equals(ChunkHelper.tIME, StringComparison.Ordinal))) { copy = true; } if (chunk is PngChunkSkipped) { copy = false; } } if (copy) { _ = chunksList.Queue(AbstractPngChunk.CloneChunk(chunk, ImgInfo)); } } }
public void CopyChunks(PngReader reader, int copy_mask, bool onlyAfterIdat) { bool flag = CurrentChunkGroup >= 4; if (onlyAfterIdat && reader.CurrentChunkGroup < 6) { throw new PngjException("tried to copy last chunks but reader has not ended"); } foreach (PngChunk chunk in reader.GetChunksList().GetChunks()) { if (chunk.ChunkGroup >= 4 || !flag) { bool flag2 = false; if (chunk.Crit) { if (chunk.Id.Equals("PLTE")) { if (ImgInfo.Indexed && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_PALETTE)) { flag2 = true; } if (!ImgInfo.Greyscale && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL)) { flag2 = true; } } } else { bool flag3 = chunk is PngChunkTextVar; bool safe = chunk.Safe; if (ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL)) { flag2 = true; } if (safe && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL_SAFE)) { flag2 = true; } if (chunk.Id.Equals("tRNS") && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_TRANSPARENCY)) { flag2 = true; } if (chunk.Id.Equals("pHYs") && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_PHYS)) { flag2 = true; } if (flag3 && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_TEXTUAL)) { flag2 = true; } if (ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALMOSTALL) && !(ChunkHelper.IsUnknown(chunk) | flag3) && !chunk.Id.Equals("hIST") && !chunk.Id.Equals("tIME")) { flag2 = true; } if (chunk is PngChunkSkipped) { flag2 = false; } } if (flag2) { chunksList.Queue(PngChunk.CloneChunk(chunk, ImgInfo)); } } } }