コード例 #1
0
        private List <Chunk> ReadAndParseChunks()
        {
            List <Chunk> chunks       = PNGFile.Read(FilepathTextBox.Text);
            List <Chunk> parsedChunks = ChunkParser.Parse(chunks);

            return(parsedChunks);
        }
コード例 #2
0
        private void FillChunkInfo(string imagePath)
        {
            List <Chunk> chunks    = ChunkParser.Parse(PNGFile.Read(imagePath));
            string       chunkInfo = GetChunksInfo(chunks);

            InfoText.Text = chunkInfo;
        }
コード例 #3
0
        public void ShouldDecipherImageWithoutFiltering()
        {
            string       filePathToRead   = @"../../../Data/square_wave_encrypted.png";
            string       filePathToWrite  = @"../../../Data/square_wave_decrypted.png";
            List <Chunk> chunks           = PNGFile.Read(filePathToRead);
            List <Chunk> parsedChunks     = ChunkParser.Parse(chunks);
            List <Chunk> decipheredChunks = imageBlockCipher.DecipherWithoutFiltering(parsedChunks);

            PNGFile.Write(filePathToWrite, decipheredChunks);
        }
コード例 #4
0
        public void ShouldParseChunks()
        {
            string       filePath = @"../../../Data/kostki.png";
            List <Chunk> chunks   = PNGFile.Read(filePath);
            List <Chunk> result   = ChunkParser.Parse(chunks);
            cHRM         expected = new cHRM(PNGFile.Read(filePath)[2]);
            cHRM         chrm     = (cHRM)result[2];

            Assert.AreEqual(expected.WhitePointX, chrm.WhitePointX);
        }
コード例 #5
0
        public void ShouldCipherLenaImageWithoutFiltering()
        {
            string       filePathToRead  = @"../../../Data/Lena.png";
            string       filePathToWrite = @"../../../Data/Lena_encrypted.png";
            List <Chunk> chunks          = PNGFile.Read(filePathToRead);
            List <Chunk> parsedChunks    = ChunkParser.Parse(chunks);
            List <Chunk> cipheredChunks  = imageBlockCipher.CipherWithoutFiltering(parsedChunks);

            PNGFile.Write(filePathToWrite, cipheredChunks);
        }
コード例 #6
0
        public void ShouldConcatAndThenSplitImage()
        {
            string       filePath       = @"../../../Data/lena.png";
            List <Chunk> chunks         = PNGFile.Read(filePath);
            List <Chunk> parsedChunks   = ChunkParser.Parse(chunks);
            int          firstIdatIndex = parsedChunks.TakeWhile(chunk => !IsIDAT(chunk)).Count();
            List <IDAT>  idats          = parsedChunks.Where(IsIDAT).Select(chunk => (IDAT)chunk).ToList();

            byte[]       bytes        = IDATConverter.ConcatToBytes(idats);
            List <Chunk> resultIdats  = IDATConverter.SplitToIDATs(bytes).Select(idat => (Chunk)idat).ToList();
            List <Chunk> resultChunks = parsedChunks.Where(chunk => !IsIDAT(chunk)).ToList();

            resultChunks.InsertRange(firstIdatIndex, resultIdats);
            PNGFile.Write(@"../../../Data/lenaConverted.png", resultChunks);
        }