C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Dynamic Watermarking Images in C#.NET


Posted Date: 22 Jun 2008    Resource Type: Code Snippets    Category: Graphics

Posted By: Raju.M       Member Level: Gold
Rating:     Points: 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  
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   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use