Example #1
0
        public override Bitmap RecoverWatermark(Bitmap watermarkedImage)
        {
            var watermarkedData  = ImageUtility.ConvertToMatrix(watermarkedImage);
            var watermarkData    = new int[_watermark.Width, _watermark.Height];
            var watermarkChannel = new int[_watermark.Width * _watermark.Height];

            RecoverChannel(watermarkedData.G, watermarkChannel);

            int k = 0;

            for (int i = 0; i < watermarkData.GetUpperBound(0) + 1; i++)
            {
                for (int j = 0; j < watermarkData.GetUpperBound(1) + 1; j++)
                {
                    watermarkData[i, j] = watermarkChannel[k++];
                }
            }

            var recoveredWatermark = ImageUtility.ConverBinaryArrayToWatermark2(watermarkData);

            return(recoveredWatermark);
        }
Example #2
0
        private void BtnRecoveredWatermarkSave_Click(object sender, EventArgs e)
        {
            //if (_recoveredWatermark == null)
            //    return;
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter       = "JPEG|*.jpg|PNG|*.png;|BMP|*.bmp;|GIF|*.gif;|TIFF|*.tiff";
            dialog.AddExtension = true;
            String destinationPath = null;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                destinationPath = dialog.FileName;
                try
                {
                    _recoveredWatermark.Save(destinationPath, ImageUtility.GetImageFormat(destinationPath));
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }
Example #3
0
        public override Bitmap EmbedWatermark(Bitmap coverImage, Bitmap watermark)
        {
            var coverData     = ImageUtility.ConvertToMatrix(coverImage);
            var watermarkData = ImageUtility.ConvertWatermarkToBinaryArray2(watermark);

            var watermarkChannel = new int[watermarkData.Length];
            int k = 0;

            for (int i = 0; i < watermarkData.GetUpperBound(0) + 1; i++)
            {
                for (int j = 0; j < watermarkData.GetUpperBound(1) + 1; j++)
                {
                    watermarkChannel[k++] = watermarkData[i, j];
                }
            }

            EmbedChannel(coverData.G, watermarkChannel);

            SetInformData(watermark);
            var watermarkedImage = ImageUtility.ConvertToBitmap(coverData);

            return(watermarkedImage);
        }