Пример #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TextExtractor" /> class.
 /// </summary>
 /// <param name="encodedImage">The encoded image.</param>
 public TextExtractor(Image encodedImage)
 {
     if (encodedImage == null)
     {
         throw new ArgumentNullException();
     }
     this.EncodedImage = (Bitmap)encodedImage;
     this.HeaderPixel  = HeaderPixel.From(this.EncodedImage.GetPixel(0, 0));
 }
        private void embedImage(HeaderPixel headerPixel)
        {
            if (headerPixel == null)
            {
                throw new ArgumentNullException();
            }
            IEmbeddor embeddor = new ImageEmbeddor(this.largePictureBox.Image, this.smallPictureBox.Image, headerPixel);

            this.largePictureBox.Image = embeddor.Embed();
            MessageBox.Show(@"Successfully embedded!", @"Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
        private void decryptImage()
        {
            var headerPixel = HeaderPixel.From(this.EncodedImage.GetPixel(0, 0));

            if (!headerPixel.IsEncrypted)
            {
                return;
            }
            var decrypter = new ImageDecryption(this.ExtractedImage);

            this.ExtractedImage = decrypter.DecryptedImage;
        }
        private void decryptButton_Click(object sender, EventArgs e)
        {
            var image       = (Bitmap)this.largePictureBox.Image;
            var headerPixel = HeaderPixel.From(image.GetPixel(0, 0));

            if (headerPixel.IsImage)
            {
                this.extractImage();
            }
            else
            {
                this.extractText();
            }
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ImageEmbeddor" /> class.
 /// </summary>
 /// <param name="hiderImage">The hider image.</param>
 /// <param name="embedImage">The embed image.</param>
 /// <param name="headerPixel">The header pixel.</param>
 /// <exception cref="ArgumentNullException">
 /// </exception>
 public ImageEmbeddor(Image hiderImage, Image embedImage, HeaderPixel headerPixel)
 {
     if (hiderImage == null)
     {
         throw new ArgumentNullException();
     }
     if (embedImage == null)
     {
         throw new ArgumentNullException();
     }
     if (headerPixel == null)
     {
         throw new ArgumentNullException();
     }
     this.HiderImage  = (Bitmap)hiderImage;
     this.EmbedImage  = (Bitmap)embedImage;
     this.HeaderPixel = headerPixel;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="TextEmbeddor" /> class.
 /// </summary>
 /// <param name="sourceImage">The source image.</param>
 /// <param name="textToEmbed">The text to embed.</param>
 /// <param name="headerPixel">The header pixel</param>
 public TextEmbeddor(Image sourceImage, string textToEmbed, HeaderPixel headerPixel)
 {
     this.SourceImage = sourceImage;
     this.MessageText = textToEmbed;
     this.HeaderPixel = headerPixel;
 }