C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Graphics »

Dynamic Watermarking Images in C#.NET


Posted Date: 22 Jun 2008    Resource Type: Code Snippets    Category: Graphics
Author: Raju.MMember Level: Gold    
Rating: 1 out of 5Points: 10



The code sample is a powerful way to watermark images dynamically. The code below watermarks ootyflower.jpg image by creating a bitmap image of the same size and writing a text across the image.

The code uses System.Drawing and System.Graphics namespaces.


//Creating Dynamic Watermark on image
System.Drawing.Image objImage = System.Drawing.Image.FromFile(Server.MapPath("ootyflower.jpg"));//From File
int height = objImage.Height;//Actual image width
int width = objImage.Width;//Actual image height
System.Drawing.Bitmap bitmapimage = new System.Drawing.Bitmap(objImage, width, height);// create bitmap with same size of Actual image
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmapimage);
//Creates a System.Drawing.Color structure from the four ARGB component
//(alpha, red, green, and blue) values. Although this method allows a 32-bit value
// to be passed for each component, the value of each component is limited to 8 bits.
//create Brush
SolidBrush brush = new SolidBrush(Color.FromArgb(113, 255, 255, 255));
//Adding watermark text on image
g.DrawString("Raju.M C# Programmer Kerala,India.Dynamic WaterMark sample", new Font("Arial", 18, System.Drawing.FontStyle.Bold), brush, 0, 100);
//save image with Watermark image/picture
//bitmapimage.Save("watermark-image.jpg"); //if u want to save image
Response.ContentType = "image/jpeg";
bitmapimage.Save(Response.OutputStream, ImageFormat.Jpeg);





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Watermarking Images Dynamically  .  Watermark text on image  .  Image Watermark using C#  .  Image Watermark in ASP.NET  .  Dynamic Watermarking  .  Dynamic Image watermark using C# and ASP.NET  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Shuffle Images in DataList using Java Script
Previous Resource: Chnaging Shape Of The Form
Return to Discussion Resource Index
Post New Resource
Category: Graphics


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use