CodeCarvings Piczard V1.2 Help
Apply A Watermark
Send Feedback
Piczard Fundamentals - Core > Built-in Filters > Apply A Watermark

Glossary Item Box


  1. Watermark base class
    1. Text watermark
    2. Image watermark



1. Watermark base class

Piczard provides 2 types of built-in watermark filters:

  1. TextWatermark class
    For more information please refer to: Text watermark
  2. ImageWatermark class
    For more information please refer to: Image watermark

Both these classes inherit from the Watermark class and are available through the CodeCarvings.Piczard.Filters.Watermarks Namespace.




1.a. Text watermark

Please see the Example A.223 - "Apply a text watermark".

This kind of watermark allows to easily draw text on an image.



Copy Code
TextWatermark watermark = new TextWatermark();
watermark.ContentAlignment = System.Drawing.ContentAlignment.TopRight;
watermark.ForeColor = Color.Yellow;
watermark.Font.Name =
watermark.Text =
"Source.jpg", "Output.jpg");

Figure 3: A text watermark.



1.b. Image watermark

Please see the Example A.224 - "Apply an image watermark".

This kind of watermark allows to easily draw an image on an image.

In order to initialize an ImageWatermark object you have to pass the watermark source image as:

  1. A file path
  2. A byte array
  3. An Image object


In the first two cases, the watermark source image is loaded - and automatically disposed - when the Watermark filter is applied.

In the third case, the watermark source  image is not disposed by the the Watermark filter.
Thus, if you have to apply the same watermark to multiple images, this is the best way.

JSON Serializer can serialize an ImageWatermark only if the object has been initialized with a file path (case no 1).



Copy Code
ImageWatermark watermark = new ImageWatermark("~/watermark.gif");
watermark.ContentAlignment = System.Drawing.ContentAlignment.BottomRight;
watermark.Alpha = 99F;
"Source.jpg", "Output.jpg");

Figure 4: An image watermark.

©2013 Sergio Turolla. All Rights Reserved.