How to add a a red colored text caption to the image in Visual C# application without any 3rd party components or libraries - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to add a a red colored text caption to the image in Visual C# application without any 3rd party components or libraries

  • Home
  • /
  • Articles
  • /
  • How to add a a red colored text caption to the image in Visual C# application without any 3rd party components or libraries

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:

sample input image

Output 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)

Tutorials:

prev
next