.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to put watermark in an image

Posted By: Ramesh     Posted Date: July 15, 2009    Points:2   Category :ASP.Net
Hi,
How to put watermark in an image while uploading by user. I need to put my company name and logo as an watermark. Please help me in that.

I am using Asp.Net and C#.

Thanks in advance

Responses
Author: Venkat             
Posted Date: September 11, 2009     Points: 5   

HI,
To put watermark on image on the fly you can use below method its written in C# and can be used in asp.net or windows application.

using System;
using System.IO;
using System.Drawing;
using System.Drawing.Image;

public void AddWatermark(string filename, string watermarkText, Stream outputStream) {
Bitmap bitmap = Bitmap.FromFile(filename);
Font font = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Pixel);
Color color = Color.FromArgb(10, 0, 0, 0); //Adds a black watermark with a low alpha value (almost transparent).
Point atPoint = new Point(100, 100); //The pixel point to draw the watermark at (this example puts it at 100, 100 (x, y)).
SolidBrush brush = new SolidBrush(color);

Graphics graphics = null;
try {
graphics = Graphics.FromImage(bitmap);
} catch {
Bitmap temp = bitmap;
bitmap = new Bitmap(bitmap.Width, bitmap.Height);
graphics = Graphics.FromImage(bitmap);
graphics.DrawImage(temp, new Rectangle(0, 0, bitmap.Width, bitmap.Height), 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel);
temp.Dispose();
}

graphics.DrawString(text, font, brush, atPoint);
graphics.Dispose();

bitmap.Save(outputStream);
}




http://forums.asp.net/t/901961.aspx

Mark As Answer if this solve your problem
Warm Regards,
Venkat
Author: Renji             
Posted Date: June 07, 2011     Points: 20   

Hi am creating 1 website..
In that when a user uploading his image it will saved to sql database and my server folder...
and i want put a water mark on that image ... while it uploading.... am creating this site using asp.net with C#.. am able to upload the image..

Please help me to do it...



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend