/// <summary>
        /// Add Watermark to Html page representation
        /// </summary>
        public static void Add_Watermark_For_Html()
        {
            Console.WriteLine("***** {0} *****", "Add Watermark to Html page representation");

            /* ********************* SAMPLE ********************* */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";

            HtmlOptions options = new HtmlOptions();

            // Set watermark properties
            Watermark watermark = new Watermark("This is watermark text");
            watermark.Color = System.Drawing.Color.Blue;
            watermark.Position = WatermarkPosition.Diagonal;
            watermark.Width = 100;

            options.Watermark = watermark;

            // Get document pages html representation with watermark
            List<PageHtml> pages = htmlHandler.GetPages(guid, options);
        }
Пример #2
0
        /// <summary>
        /// Adds a text based watermark to the current image.
        /// </summary>
        /// <param name="textLayer">
        /// The <see cref="T:ImageProcessor.Imaging.TextLayer"/> containing the properties necessary to add
        /// the text based watermark to the image.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Watermark(TextLayer textLayer)
        {
            if (this.ShouldProcess)
            {
                Watermark watermark = new Watermark {
                    DynamicParameter = textLayer
                };
                this.ApplyProcessor(watermark.ProcessImage);
            }

            return(this);
        }
Пример #3
0
    public void UpdatesHidePropertyWhenWatermarkTextIsSet(string initialText, bool hide)
    {
        TextBox box;


        box = new TextBox {
            Text = initialText
        };

        Watermark.SetText(box, "foo");

        Assert.Equal(hide, Watermark.GetHide(box));
    }
 private static Writer.Data.Watermark CopyWatermark(Watermark watermark)
 {
     if (watermark == null)
     {
         return(null);
     }
     return(new Writer.Data.Watermark
     {
         ImageSource = watermark.ImageSource,
         Opacity = watermark.Opacity,
         Size = watermark.Size
     });
 }
        // Create a watermark with the specified text.
        private Watermark CreateTextWatermark(string text)
        {
            Watermark textWatermark = new Watermark();

            textWatermark.Text             = text;
            textWatermark.TextDirection    = DirectionMode.ForwardDiagonal;
            textWatermark.Font             = new Font(textWatermark.Font.FontFamily, 40);
            textWatermark.ForeColor        = Color.DodgerBlue;
            textWatermark.TextTransparency = 150;
            textWatermark.ShowBehind       = false;

            return(textWatermark);
        }
Пример #6
0
        public static T ExtractWatermark <T>(PNGFile file, string password)
        {
            Watermark m         = ExtractWatermark(file, password);
            T         converted = default(T);

            try
            {
                converted = (T)Convert.ChangeType(m, typeof(T));
            }
            catch (Exception ex) { }

            return(converted);
        }
Пример #7
0
        public void ConfigureWatermark_TopLeftP720()
        {
            VideoStandard videoStandard = VideoStandards.P720;
            Watermark     watermark     = Watermark.ConfigureNewWatermark(WatermarkPosition.TOP_LEFT, videoStandard);

            var expectedOffsetX = Sizes.WatermarkPadding / (double)videoStandard.Width;
            var expectedOffsetY = Sizes.WatermarkPadding / (double)videoStandard.Height;
            int expectedHeight  = (int)(videoStandard.Height * Sizes.WatermarkHeightNormalization);

            Assert.AreEqual(expectedOffsetX, watermark.OffsetX);
            Assert.AreEqual(expectedOffsetY, watermark.OffsetY);
            Assert.AreEqual(expectedHeight, watermark.Image.Height);
        }
Пример #8
0
        private Watermark CreateTextWatermark(string text)
        {
            Watermark textWatermark = new Watermark();

            textWatermark.Text             = text;
            textWatermark.TextDirection    = DirectionMode.ForwardDiagonal;
            textWatermark.Font             = new Font("Tahoma", 108);
            textWatermark.ForeColor        = Color.Red;
            textWatermark.TextTransparency = 150;
            textWatermark.ShowBehind       = false;

            return(textWatermark);
        }
        public MainWindow()
        {
            InitializeComponent();

            _imageLocation              = AppDomain.CurrentDomain.BaseDirectory + "original.jpg";
            _watermarkImageLocation     = AppDomain.CurrentDomain.BaseDirectory + "embeddedwatermark.jpg";
            _recoveredWatermarkLocation = AppDomain.CurrentDomain.BaseDirectory + "recoveredwatermark.jpg";

            var fileBytes = File.ReadAllBytes(_imageLocation);

            RenderImageBytes(OriginalImage, fileBytes);

            _watermark = new Watermark(true);
        }
Пример #10
0
    public void SetsHideToTrueWhenTheTextBoxContainsWhitespace()
    {
        TextBox box;


        box = new TextBox();
        Watermark.SetText(box, "foo");

        Assert.False(Watermark.GetHide(box));

        box.Text = " ";

        Assert.True(Watermark.GetHide(box));
    }
        // Token: 0x06000222 RID: 546 RVA: 0x0000C0E0 File Offset: 0x0000A2E0
        protected override void UpdateWatermarksForAssistant(Guid assistantId)
        {
            long watermark = this.dispatcher.GetWatermark(base.HighestEventPolled);

            if (watermark != base.DatabaseBookmark[assistantId])
            {
                ExTraceGlobals.EventControllerTracer.TraceDebug <EventControllerPublic, long>((long)this.GetHashCode(), "{0}: Saving database watermark at {1}", this, watermark);
                base.EventAccess.SaveWatermarks(assistantId, new Watermark[]
                {
                    Watermark.GetDatabaseWatermark(watermark)
                });
                base.DatabaseBookmark[assistantId] = watermark;
            }
        }
Пример #12
0
 public ImageAttrModel(Watermark watermark)
 {
     if (watermark != null)
     {
         Id                    = watermark.Id;
         PhotoId               = watermark.PhotoId;
         IsWatermarkApplied    = watermark.IsWatermarkApplied;
         IsWatermarkBlack      = watermark.IsWatermarkBlack;
         IsSignatureApplied    = watermark.IsSignatureApplied;
         IsSignatureBlack      = watermark.IsSignatureBlack;
         IsWebSiteTitleApplied = watermark.IsWebSiteTitleApplied;
         IsWebSiteTitleBlack   = watermark.IsWebSiteTitleBlack;
         IsRightSide           = watermark.IsRightSide;
     }
 }
Пример #13
0
 private string DetectInvisibleWatermark() //Extract invisible watermark
 {
     water = new Watermark(_boxSize, _errorCorrection, _opacity, _s1, _s2);
     using (CStreamReader reader = InputPicture.CreateReader())
     {
         using (Bitmap bitmap = new Bitmap(reader))
         {
             if (_stopped)
             {
                 return("");
             }
             return(water.extractText(bitmap));
         }
     }
 }
Пример #14
0
        public void ConfigureWatermark_BottomRightP480()
        {
            int           expectedHeight, expectedWidth;
            VideoStandard videoStandard = VideoStandards.P480;
            Watermark     watermark     = Watermark.ConfigureNewWatermark(WatermarkPosition.BOTTOM_RIGHT, videoStandard);

            expectedHeight = expectedWidth = (int)(videoStandard.Height * Sizes.WatermarkHeightNormalization);
            var expectedOffsetX = (videoStandard.Width - expectedWidth - Sizes.WatermarkPadding) / (double)videoStandard.Width;
            var expectedOffsetY = (videoStandard.Height - expectedHeight - Sizes.WatermarkPadding) / (double)videoStandard.Height;


            Assert.AreEqual(expectedOffsetX, watermark.OffsetX);
            Assert.AreEqual(expectedOffsetY, watermark.OffsetY);
            Assert.AreEqual(expectedHeight, watermark.Image.Height);
        }
Пример #15
0
        protected virtual void OnButtonOkClicked(object sender, System.EventArgs e)
        {
            TreeIter iter;

            /* Get size info */
            sizecombobox.GetActiveIter(out iter);
            encSettings.VideoStandard = (VideoStandard)stdStore.GetValue(iter, 1);

            /* Get encoding profile info */
            formatcombobox.GetActiveIter(out iter);
            encSettings.EncodingProfile = (EncodingProfile)encStore.GetValue(iter, 1);

            /* Get quality info */
            qualitycombobox.GetActiveIter(out iter);
            encSettings.EncodingQuality = (EncodingQuality)qualStore.GetValue(iter, 1);

            encSettings.OutputFile = mediafilechooser1.CurrentPath;

            encSettings.Framerate_n = App.Current.Config.FPS_N;
            encSettings.Framerate_d = App.Current.Config.FPS_D;

            encSettings.TitleSize = 20;

            encSettings.EnableAudio = audiocheckbutton.Active;
            encSettings.EnableTitle = descriptioncheckbutton.Active;

            if (watermarkcheckbutton.Active)
            {
                encSettings.Watermark = Watermark.ConfigureNewWatermark(WatermarkPosition.TOP_RIGHT, encSettings.VideoStandard, App.Current.Config.Watermark);
            }
            else
            {
                encSettings.Watermark = null;
            }

            if (!SplitFiles && String.IsNullOrEmpty(EncodingSettings.OutputFile))
            {
                App.Current.Dialogs.WarningMessage(Catalog.GetString("Please, select a video file."));
            }
            else if (SplitFiles && String.IsNullOrEmpty(OutputDir))
            {
                App.Current.Dialogs.WarningMessage(Catalog.GetString("Please, select an output directory."));
            }
            else
            {
                Respond(ResponseType.Ok);
            }
        }
Пример #16
0
    public void SetsHideToFalseWhenTheTextBoxDoesNotContainText(string watermark)
    {
        TextBox box;


        box = new TextBox();
        Watermark.SetText(box, "foo");

        box.Text = "bar";

        Assert.True(Watermark.GetHide(box));

        box.Text = watermark;

        Assert.False(Watermark.GetHide(box));
    }
Пример #17
0
 private void CreateInvisibleWatermark() //Embed invisible Watermark
 {
     water = new Watermark(_boxSize, _errorCorrection, _opacity, _s1, _s2);
     using (CStreamReader reader = InputPicture.CreateReader())
     {
         using (Bitmap bitmap = new Bitmap(reader))
         {
             if (_stopped)
             {
                 return;
             }
             water.embed(bitmap, Watermark);
             CreateOutputStream(bitmap);
         }
     }
 }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.productsTableAdapter.Fill(this.nwindDataSet.Products);

            radioGroup1.SelectedIndex = 0;

            Watermark wm = printableComponentLink1.PrintingSystem.Watermark;

            wm.Text          = "Change the Watermark,\r\nthen close and re-open\r\nthe form.";
            wm.ShowBehind    = false;
            wm.TextDirection = DirectionMode.Horizontal;

            SaveWatermark(printableComponentLink1, WatermarkStorage.Registry);
            SaveWatermark(printableComponentLink1, WatermarkStorage.Stream);
            SaveWatermark(printableComponentLink1, WatermarkStorage.XML);
        }
 internal void Instantiate(Watermark watermark, DatabaseId databaseId, long lastDatabaseCounter, Server server, bool isDatabaseCopyActive)
 {
     if (watermark == null)
     {
         throw new ArgumentNullException("watermark");
     }
     if (null == databaseId)
     {
         throw new ArgumentNullException("databaseId");
     }
     this.watermark           = watermark;
     this.databaseId          = databaseId;
     this.lastDatabaseCounter = lastDatabaseCounter;
     this.server = server;
     this.isDatabaseCopyActive = isDatabaseCopyActive;
 }
Пример #20
0
            /// <summary>
            /// add a watermark text to all rendered images.
            /// </summary>
            /// <param name="options">HtmlOptions by reference</param>
            /// <param name="text">Watermark text</param>
            /// <param name="color">System.Drawing.Color</param>
            /// <param name="position"></param>
            /// <param name="width"></param>
            public static void AddWatermark(ref ImageOptions options, String text, Color color, WatermarkPosition position, int width)
            {
                //ExStart:AddWatermark
                //Initialize watermark object by passing the text to display.
                Watermark watermark = new Watermark(text);

                //Apply the watermark color by assigning System.Drawing.Color.
                watermark.Color = color;
                //Set the watermark's position by assigning an enum WatermarkPosition's value.
                watermark.Position = position;
                //set an integer value as watermark width
                watermark.Width = width;
                //Assign intialized and populated watermark object to ImageOptions or HtmlOptions objects
                options.Watermark = watermark;
                //ExEnd:AddWatermark
            }
Пример #21
0
        /// <summary>
        /// 增加水印
        /// </summary>
        /// <param name="fr">Report对象实体</param>
        /// <param name="str">水印文字</param>
        /// <param name="size"></param>
        /// <returns>Report对象实体</returns>
        private void AddWatermark(Report fr, string str, int size = 72)
        {
            var wm = new Watermark
            {
                Enabled = true,
                Text    = str,
                Font    = new Font("宋体", size, FontStyle.Bold)
            };

            for (var i = 0; i < fr.PreparedPages.Count; i++)
            {
                var pag = fr.PreparedPages.GetPage(i);
                pag.Watermark = wm;
                fr.PreparedPages.ModifyPage(i, pag);
            }
        }
Пример #22
0
        public static void Print(GridControl pivotcontrol, string header, string watermark)
        {
            PrintingSystem         printingSystem1         = new PrintingSystem();
            PrintableComponentLink printableComponentLink1 = new PrintableComponentLink();

            printingSystem1.Links.Add(printableComponentLink1);
            printableComponentLink1.Component = pivotcontrol;
            printableComponentLink1.Landscape = true;
            printableComponentLink1.ClearDocument();
            //设置纸张
            printableComponentLink1.PaperKind      = System.Drawing.Printing.PaperKind.A4;
            printableComponentLink1.Margins.Bottom = 40;
            printableComponentLink1.Margins.Top    = 80;
            printableComponentLink1.Margins.Right  = 20;
            printableComponentLink1.Margins.Left   = 20;
            //水印
            Watermark textWatermark = new Watermark();

            // Set watermark options.
            textWatermark.Text             = watermark;
            textWatermark.TextDirection    = DirectionMode.ForwardDiagonal;
            textWatermark.Font             = new Font(textWatermark.Font.FontFamily, 40);
            textWatermark.ForeColor        = Color.Red;
            textWatermark.TextTransparency = 150;
            textWatermark.ShowBehind       = false;
            //textWatermark.PageRange = "1,3-5";
            printingSystem1.Watermark.CopyFrom(textWatermark);
            //设置页眉
            string leftColumn   = "";
            string middleColumn = header;
            string rightColumn  = "";
            string bottomleft   = "打印时间:[已打印数据][打印耗时]";
            string bottommiddle = "第[页#]页";
            string bottomright  = "";
            // Create a PageHeaderFooter object and initializing it with
            // the link's PageHeaderFooter.
            PageHeaderFooter phf = printableComponentLink1.PageHeaderFooter as PageHeaderFooter;

            // Clear the PageHeaderFooter's contents.
            //phf.Header.Content.Clear();
            // Add custom information to the link's header.
            phf.Header.Content.AddRange(new string[] { leftColumn, middleColumn, rightColumn });
            phf.Footer.Content.AddRange(new string[] { bottomleft, bottommiddle, bottomright });
            phf.Header.LineAlignment = BrickAlignment.Near;
            printableComponentLink1.ShowPreview();
        }
Пример #23
0
        public async Task <IActionResult> AddFile(IFormFile file)
        {
            _logger.LogInformation("Выполнение метода AddFile");
            if (file != null)
            {
                _logger.LogInformation("Файл имеет размер {0}", file.Length);

                byte[] img = new byte[file.Length];
                using (var stream = new MemoryStream(img))
                {
                    await file.CopyToAsync(stream);

                    _logger.LogInformation("Записали поток в MemoryStream");
                    try
                    {
                        _logger.LogInformation("Создаем Bitmap image");
                        using (Bitmap bitmap = new Bitmap(stream))
                        {
                            _logger.LogInformation("Bitmap image создан");

                            Bitmap bmnew = Watermark.WaterMarkToImage(bitmap, "test text");

                            if (bmnew != null && !bmnew.Size.IsEmpty)
                            {
                                bmnew.Save("wwwroot/i2.jpg");
                                _logger.LogInformation("Файл сохранен");
                            }
                            else
                            {
                                _logger.LogInformation("Ошибка обработки Watermark");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.LogInformation("Bitmap image не создан");
                        _logger.LogInformation(e.Message);
                    }
                }
            }
            else
            {
                _logger.LogInformation("Файл не существует");
            }
            return(RedirectToAction("Index"));
        }
Пример #24
0
        public override object EditValue(ITypeDescriptorContext context,
                                         IServiceProvider provider, object Value)
        {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            Watermark watermark = Value as Watermark;

            using (WatermarkEditorForm editor = new WatermarkEditorForm())
            {
                editor.Watermark = watermark;
                editor.HideApplyToAll();
                if (editor.ShowDialog() == DialogResult.OK)
                {
                    watermark = editor.Watermark;
                }
            }
            return(watermark);
        }
Пример #25
0
        private void OnKoiRequested(object sender, RequestKoiEventArgs e)
        {
            var header = new HeaderChunk(this);

            foreach (var block in basicBlocks)
            {
                finalChunks.Add(block.Item2.CreateChunk(this, block.Item1));
            }
            finalChunks.AddRange(extraChunks);
            finalChunks.Add(new BinaryChunk(Watermark.GenerateWatermark((uint)settings.Seed)));
            Descriptor.Random.Shuffle(finalChunks);
            finalChunks.Insert(0, header);

            ComputeOffsets();
            FixupReferences();
            header.WriteData(this);
            e.Heap = CreateHeap();
        }
Пример #26
0
        public Main()
        {
            InitializeComponent();

            defaultContext = new DefaultContext();

            List <String> tableNames = defaultContext.GetScheme();

            import = new Import(defaultContext, tables_cb, tableNames);
            export = new Export(defaultContext, tables_cb_e, tableNames);
            marker = new Watermark(defaultContext);

            export_bt.Enabled = true;
            delete_pb.Visible = false;
            delete_pb.Minimum = 1;
            delete_pb.Maximum = 11;
            delete_pb.Value   = 1;
            delete_pb.Step    = 1;
        }
Пример #27
0
        /// <summary>
        /// Adds watermark on document if its specified in configuration file.
        /// </summary>
        /// <param name="options"></param>
        private static void SetWatermarkOptions(ViewOptions options)
        {
            Watermark watermark = null;

            if (!string.IsNullOrEmpty(globalConfiguration.GetViewerConfiguration().GetWatermarkText()))
            {
                // Set watermark properties
                watermark = new Watermark(globalConfiguration.GetViewerConfiguration().GetWatermarkText())
                {
                    Color    = System.Drawing.Color.Blue,
                    Position = Position.Diagonal,
                };
            }

            if (watermark != null)
            {
                options.Watermark = watermark;
            }
        }
Пример #28
0
        public void EmitWatermark(Watermark mark)
        {
            _watermarkGauge.Value           = mark.Timestamp;
            _serializationDelegate.Instance = mark;

            if (!_streamStatusProvider.StreamStatus.IsActive)
            {
                return;
            }

            try
            {
                _recordWriter.BroadcastEmit(_serializationDelegate);
            }
            catch (Exception e)
            {
                throw new RuntimeException(e.Message, e);
            }
        }
Пример #29
0
        public MainWindow()
        {
            InitializeComponent();

            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\dist\\"))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\dist\\");
            }

            _imageLocation = AppDomain.CurrentDomain.BaseDirectory + "";
            //_watermarkImageLocation = AppDomain.CurrentDomain.BaseDirectory + "/dist/embeddedwatermark.jpg";
            _watermarkImageLocation     = "";
            _recoveredWatermarkLocation = AppDomain.CurrentDomain.BaseDirectory + "/dist/recoveredwatermark.jpg";

            //var fileBytes = File.ReadAllBytes(_imageLocation);
            //RenderImageBytes(OriginalImage, fileBytes);

            _watermark = new Watermark(true);
        }
Пример #30
0
        /// <summary>
        /// Embeds a given watermark into a PNG file and saves the result.
        /// </summary>
        /// <param name="file">PNGFile to use in the watermarking process.</param>
        /// <param name="mark">The watermark to embed.</param>
        /// <param name="password">A password for the embedding process</param>
        /// <param name="outputPath">Location of the saved file.</param>
        public static void EmbedWatermark(PNGFile file, Watermark mark, string password, string outputPath)
        {
            Rfc2898DeriveBytes bytes = new Rfc2898DeriveBytes(password, new byte[] { 112, 52, 63, 42, 180, 121, 53, 27 }, 1000);

            PNGScrambler scrambler = new PNGScrambler(file, bytes.GetBytes(16), bytes.GetBytes(8));

            byte[] markBytes = mark.GetBytes();

            if (ReedSolomonProtection == false)
            {
                EmbedData(markBytes, scrambler);
            }
            else
            {
                markBytes = EncodeWithReedSolomon(markBytes);
                EmbedData(markBytes, scrambler);
            }

            file.SaveAs(outputPath);
        }
Пример #31
0
        private void btn_LoadWM_Embed_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "jpg files (*.jpg)|*.jpg|png files (*.png)|*.png|All files (*.*)|*.*";
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string filename = openFileDialog1.FileName;

            using (Bitmap imageBitmap = new Bitmap(filename))
            {
                DoubleImage dImage = new DoubleImage(imageBitmap);
                watermark_Embed = new Watermark(dImage);
            }
            btn_Embed.Enabled     = true;
            txt_Status_Embed.Text = "ЦВЗ загружен.";
        }
        /// <summary>
        /// Perform multiple transformations in Image mode
        /// </summary>
        public static void Multiple_Transformations_For_Image()
        {
            Console.WriteLine("***** {0} *****", "Perform multiple transformations in Image mode");

            /* ********************* SAMPLE ********************* */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create image handler
            ViewerImageHandler imageHandler = new ViewerImageHandler(config);
            string guid = "word.doc";

            // Rotate first page 90 degrees
            imageHandler.RotatePage(new RotatePageOptions(guid, 1, 90));

            // Rotate second page 180 degrees
            imageHandler.RotatePage(new RotatePageOptions(guid, 2, 180));

            // Reorder first and second pages
            imageHandler.ReorderPage(new ReorderPageOptions(guid, 1, 2));

            // Set options to include rotate and reorder transformations
            ImageOptions options = new ImageOptions { Transformations = Transformation.Rotate | Transformation.Reorder };

            // Set watermark properties
            Watermark watermark = new Watermark("This is watermark text")
            {
                Color = System.Drawing.Color.Blue,
                Position = WatermarkPosition.Diagonal,
                Width = 100
            };

            options.Watermark = watermark;

            // Get document pages image representation with multiple transformations
            List<PageImage> pages = imageHandler.GetPages(guid, options);
        }
Пример #33
0
        public void OutputWatermarkToJson()
        {
            const string One = @"{{""input"":""http://example.com/file-name.avi"",""outputs"":[{{""watermarks"":[{{""height"":""24"",""url"":""s3://bucket/watermark_file.png"",""width"":""32"",""x"":""20"",""y"":""-10%""}}]}}],""api_key"":""{0}""}}";

            Watermark watermark = new Watermark()
            {
                Url = "s3://bucket/watermark_file.png",
                X = "20",
                Y = "-10%"
            };

            Output[] outputs = new Output[] { new Output().WithWatermark(watermark.WithSizeInPixels(32, 24)) };

            CreateJobRequest request = new CreateJobRequest(Zencoder)
            {
                Input = "http://example.com/file-name.avi",
                Outputs = outputs
            };

            Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, One, ApiKey), request.ToJson());
        }