Tutorial: how to add watermark to a picture using built-in .NET functionality
Looking for a component to add watermarks based on ready-to-use presets?
Check Bytescout Watermarking SDK for .NET to add more attractive watermarks with ready-to-use customizable presets
This tutorial demonstrates how to add a red text (watermark) to the photo file using .NET built-in functionality without any 3rd party components and libraries (like our Watermarking SDK) in Visual C# application
Download source code for this example: HowToAddWatermarkToImageInDotNetWithout3rdPartyTools_cs.zip (300 KB)
Input image:
Output image:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Text;
namespace WithoutDotNet
{
class Program
{
static void Main(string[] args)
{
// Load image
Image image = Image.FromFile(“my_sample_image.jpg”);
// Create graphics from image
Graphics graphics = Graphics.FromImage(image);
// Create font
Font font = new Font(“Times New Roman”, 42.0f);
// Create text position
PointF point = new PointF(150, 150);
// Draw text
graphics.DrawString(“Watermark”, font, Brushes.Red, point);
// Save image
image.Save(“my_sample_output.jpg”);
// Open generated image file in default image viewer installed in Windows
Process.Start(“my_sample_output.jpg”);
}
}
}
Download source code for this example: HowToAddWatermarkToImageInDotNetWithout3rdPartyTools_cs.zip (300 KB)
Sorry! This product is not available.
Please click here to visit main page for the list of all available products and solutions.
Product Links: