示例#1
0
        public void TestWritingChunksProducesIdenticalBytesAsInput()
        {
            byte[] input = Simple10x10WhitePNG;
            using (MemoryStream stream = new MemoryStream(Simple10x10WhitePNG))
            {
                PNGChunk[] chunks = PNGChunkParser.ChunksFromStream(stream).ToArray();

                MemoryStream output = new MemoryStream();
                PNGChunkParser.WriteChunksAsPNG(chunks, output);

                byte[] outputBytes = output.ToArray();

                CollectionAssert.AreEqual(input, outputBytes);
            }
        }
示例#2
0
        public void TestWritingChunksAfterRecalculatingCRCProducesIdenticalBytesAsInput()
        {
            byte[] input = Simple10x10WhitePNG;
            using (MemoryStream stream = new MemoryStream(Simple10x10WhitePNG))
            {
                PNGChunk[] chunks = PNGChunkParser.ChunksFromStream(stream).ToArray();
                chunks = chunks.Select(c =>
                {
                    return(new PNGChunk(c.TypeString, c.Data, PNGDecrusher.CalculateCRCForChunk(c.TypeString, c.Data)));
                }).ToArray();

                MemoryStream output = new MemoryStream();
                PNGChunkParser.WriteChunksAsPNG(chunks, output);

                byte[] outputBytes = output.ToArray();

                CollectionAssert.AreEqual(input, outputBytes);
            }
        }
示例#3
0
        private static void DecrushAtChunkLevel(Stream input, Stream output)
        {
            IEnumerable <PNGChunk> fixedChunks = DecrushChunks(PNGChunkParser.ChunksFromStream(input));

            PNGChunkParser.WriteChunksAsPNG(fixedChunks, output);
        }