Thursday, April 7, 2011

Making a watermark on any image

 ///Locate Image from Image folder.
        System.Drawing.Image objImage = System.Drawing.Image.FromFile(Server.MapPath("photo.jpg"));
        //Taken Actual width anf height From Image
        int height = objImage.Height;//height
        int width = objImage.Width;//Width
        //Create a Bitmap Image
        System.Drawing.Bitmap bitmapimage = new System.Drawing.Bitmap(objImage, width, height);// create bitmap with same size of Actual image
        //Convert in to a Graphics object
        System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmapimage);
        //Creating Brushe
        System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 255, 255, 255));
        g.RotateTransform(-90);
        //g.TranslateTransform(150, 0);
        g.DrawString("Astromilan.com", new Font("Arial", 18, System.Drawing.FontStyle.Bold), brush, -230, 50);
        Response.ContentType = "image/jpeg";//setting ContentType
        bitmapimage.Save(Response.OutputStream, ImageFormat.Jpeg);//save image with dynamic watermark

No comments:

Post a Comment

Total Pageviews