Click here to Skip to main content
13,357,610 members (65,841 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 3 Feb 2012

How to Create watermarked images in C# ASP.NET ?

, 3 Feb 2012
Rate this:
Please Sign up or sign in to vote.
How to Create watermarked images in C# ASP.NET ?
The below code will create a watermark on image using C#.

//Use NameSpace
using System.Drawing;

//Execute below code at the event, where u wants Water Marking. 
           // Create a bitmap object of the Image, Here I am taking image from File Control "FileTest" 
            Bitmap bmp = new Bitmap(FileTest.PostedFile.InputStream); 
            Graphics canvas = Graphics.FromImage(bmp); 
                Bitmap bmpNew = new Bitmap(bmp.Width, bmp.Height); 
                canvas = Graphics.FromImage(bmpNew); 
                canvas.DrawImage(bmp, new Rectangle(0, 0, 
bmpNew.Width, bmpNew.Height), 0, 0, bmp.Width, bmp.Height, 
                bmp = bmpNew; 
            catch(Exception ee) // Catch exceptions 
            // Here replace "Text" with your text and you also can assign Font Family, Color, Position Of Text etc. 
            canvas.DrawString("Text", new Font("Verdana", 14, 
FontStyle.Bold), new SolidBrush(Color.Beige), (bmp.Width / 2), 
(bmp.Height / 2)); 
            // Save or display the image where you want. 
WaterMarkImages/") + 

You will find a great solution. :-D


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...


Comments and Discussions

QuestionImage is corrupted when that image is dowloaded. Pin
Md. Ikram Shams30-Jun-13 2:07
memberMd. Ikram Shams30-Jun-13 2:07 
AnswerRe: Image is corrupted when that image is dowloaded. Pin
jorgeaikido20-Aug-15 7:27
memberjorgeaikido20-Aug-15 7:27 
Questionwatermark on images Pin
Tarcode Michael5-Jan-13 18:13
memberTarcode Michael5-Jan-13 18:13 
This is really great, I generates some bar codes and want to put some watermark. Not sure if it will affect scanning, but will have a try.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 3 Feb 2012
Article Copyright 2012 by Sarvesh Kumar Gupta
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid