Esempio n. 1
0
        /// <summary>
        ///     Embeds the secret image in the OriginalImage.
        /// </summary>
        public async Task EmbedSecretImage(bool encrypt)
        {
            var secretImageData = this.EncryptedSecretImage != null
                ? await ImageUtilities.GetImageData(this.EncryptedSecretImage)
                : await ImageUtilities.GetImageData(this.SecretImage);

            var originalImageData = await ImageUtilities.GetImageData(this.OriginalImage);

            var imageEncoder = new ImageEncoder();

            byte[] modifiedImageData;

            if (encrypt)
            {
                modifiedImageData =
                    imageEncoder.EncodeImage(originalImageData, this.OriginalImage.PixelWidth,
                                             secretImageData, this.OriginalImage.PixelWidth, this.OriginalImage.PixelHeight);
            }
            else
            {
                modifiedImageData =
                    imageEncoder.EncodeImage(originalImageData, this.OriginalImage.PixelWidth,
                                             secretImageData, this.SecretImage.PixelWidth, this.SecretImage.PixelHeight);
            }

            modifiedImageData = HeaderUtilities.AddHeader(modifiedImageData, this.OriginalImage.PixelWidth, encrypt, 1,
                                                          MessageType.MonochromeBmp);

            this.ModifiedImage    = new WriteableBitmap(this.OriginalImage.PixelWidth, this.OriginalImage.PixelHeight);
            using var writeStream = this.ModifiedImage.PixelBuffer.AsStream();
            await writeStream.WriteAsync(modifiedImageData, 0, modifiedImageData.Length);
        }
Esempio n. 2
0
        /// <summary>
        ///     Embeds the secret text message.
        /// </summary>
        public async Task EmbedSecretMessage(int bitsPerColorChannel, bool encrypt)
        {
            var originalImageData = await ImageUtilities.GetImageData(this.OriginalImage);

            var textEncoder = new TextEncoder(bitsPerColorChannel);

            var modifiedImageData = textEncoder.EncodeMessage(originalImageData, this.SecretMessage);

            modifiedImageData = HeaderUtilities.AddHeader(modifiedImageData, this.OriginalImage.PixelWidth, encrypt,
                                                          bitsPerColorChannel,
                                                          MessageType.Text);

            this.ModifiedImage = new WriteableBitmap(this.OriginalImage.PixelWidth, this.OriginalImage.PixelHeight);

            using var writeStream = this.ModifiedImage.PixelBuffer.AsStream();
            await writeStream.WriteAsync(modifiedImageData, 0, modifiedImageData.Length);
        }