private void BtnEmbedWatermark_Click(object sender, RoutedEventArgs e)
        {
            var fileBytes = File.ReadAllBytes(_imageLocation);

            var sw            = Stopwatch.StartNew();
            var embeddedBytes = _watermark.EmbedWatermark(fileBytes);

            //var embeddedBytes = _watermark.RetrieveAndEmbedWatermark(fileBytes).WatermarkedImage;
            sw.Stop();

            EmbedTime.Text          = String.Format("{0}ms", sw.ElapsedMilliseconds);
            _watermarkImageLocation = AppDomain.CurrentDomain.BaseDirectory + "embeddedwatermark.jpg";

            File.WriteAllBytes(_watermarkImageLocation, embeddedBytes);
            RenderImageBytes(WatermarkedImage, embeddedBytes);
        }
Beispiel #2
0
        private void BtnEmbedWatermark_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(_imageLocation) || !File.Exists(_imageLocation))
            {
                System.Windows.Forms.MessageBox.Show("请先载入原图", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                var fileBytes = File.ReadAllBytes(_imageLocation);

                var sw            = Stopwatch.StartNew();
                var embeddedBytes = _watermark.EmbedWatermark(fileBytes);
                //var embeddedBytes = _watermark.RetrieveAndEmbedWatermark(fileBytes).WatermarkedImage;
                sw.Stop();

                EmbedTime.Text          = String.Format("{0}ms", sw.ElapsedMilliseconds);
                _watermarkImageLocation = AppDomain.CurrentDomain.BaseDirectory + "dist\\embeddedwatermark.jpg";

                File.WriteAllBytes(_watermarkImageLocation, embeddedBytes);
                RenderImageBytes(WatermarkedImage, embeddedBytes);
            }
        }