How to add simple semitransparent visual text watermark in C# application using Bytescout.Watermarking SDK for .NET

This sample demonstrates how to add simple transparent text watermark to the image file using Bytescout.Watermarking SDK for .NET in Visual C#

Download source code: watermarkingsdk_c_sharp.zip (240 KB)

Input image:

sample input image

Output image:

Sample output image with transparent text watermark added

using System;
using System.Diagnostics;
using System.Drawing;
using System.Collections.Generic;

using Bytescout.Watermarking;
using Bytescout.Watermarking.Presets;

namespace Sample
{
class Program
{
static void Main(string[] args)
{
// Create Watermarker instance
Watermarker waterMarker = new Watermarker();

// Initialize library
waterMarker.InitLibrary(“demo”, “demo”);

// Set input file name
string inputFilePath = “my_sample_image.jpg”;
// Set output file title
string outputFilePath = “my_sample_output.jpg”;

// Add image to apply watermarks to
waterMarker.AddInputFile(inputFilePath, outputFilePath);

// Create new watermark
TextFitsPage preset = new TextFitsPage();

// Set watermark text
preset.Text = “Bytescout Watermarking”;

// Add watermark to watermarker
waterMarker.AddWatermark(preset);

// Set output directory
waterMarker.OutputOptions.OutputDirectory = “.”;

// Apply watermarks
waterMarker.Execute();

// open generated image file in default image viewer installed in Windows
Process.Start(outputFilePath);
}
}
}

Download source code: watermarkingsdk_c_sharp.zip (240 KB)