Ejemplo n.º 1
0
        public void ShouldReadEncryptedBinaryInputMessageRight()
        {
            Bitmap        binaryImage            = new Bitmap(binaryImagePath);
            Bitmap        cleanImage             = new Bitmap(cleanImagePathRight);
            string        loadedImageContent     = MessageConverter.Instance.BinaryImageToBit(binaryImage, binaryImage.Width, binaryImage.Height);
            HSHeader      header                 = new HSHeader(MessageType.BinaryImage, loadedImageContent.Length, binaryImage.Width, binaryImage.Height);
            IInputMessage inputMessageWithHeader = new InputMessage(loadedImageContent, header);
            Bitmap        encryptedImage         = HS.Instance.Encode(cleanImage, inputMessageWithHeader);

            Dictionary <int, int>      histogram = HS.Instance.calculateHistogram(cleanImage);
            Tuple <int, int, int, int> myTuple   = HS.Instance.findMinAndMax(histogram);
            int minIndex = myTuple.Item3;
            int maxIndex = myTuple.Item4;

            OutputMessage outputMessage = HS.Instance.Decode(encryptedImage, minIndex, maxIndex);
            string        withoutHeader = outputMessage.GetContent().Substring((int)HSHeaderConstants.BinaryImageHeaderLength);

            Assert.AreEqual(loadedImageContent, withoutHeader);

            Bitmap drawnImage = ImageDrawer.Instance.DrawBinaryImage(withoutHeader, outputMessage.GetHeaderData().GetImageWidth(), outputMessage.GetHeaderData().GetImageHeight());

            drawnImage.Save(savePath + DateTime.Now.ToString("yyyy-dd-MM-HH-mm-ss") + ".png");
        }