コード例 #1
0
 public void CopyChunksFirst(PngReader reader, int copy_mask) => CopyChunks(reader, copy_mask, false);
コード例 #2
0
 public void CopyChunksLast(PngReader reader, int copy_mask) => CopyChunks(reader, copy_mask, true);
コード例 #3
0
        /// <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>
        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 System.Exception("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                // 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) && 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));
                }
            }
        }
 public static long GetCrctestVal(PngReader reader) => reader.GetCrctestVal();
 public static void InitCrcForTests(PngReader reader) => reader.InitCrctest();
コード例 #6
0
 public static long GetCrctestVal(PngReader pngr)
 {
     return(pngr.GetCrctestVal());
 }
コード例 #7
0
 public static void InitCrcForTests(PngReader pngr)
 {
     pngr.InitCrctest();
 }