How can you Watermark an Image

using System.Drawing.Imaging;
using System.Drawing;


in File class1.C#

public class Class1:IHttpHandler
{
    public Class1()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    #region IHttpHandler Members

    public bool IsReusable
    {
        get { return false; }
    }

    public void ProcessRequest(HttpContext context)
    {
        string path = context.Request.PhysicalPath;
        Bitmap b = new Bitmap(path);
        Graphics g = Graphics.FromImage(b);
        StringFormat sformat = new StringFormat();
        sformat.Alignment = StringAlignment.Center;
        sformat.LineAlignment = StringAlignment.Center;
        Font f=new Font("Arial",(float)b.Width/5);
        g.DrawString("Keshav", f, new SolidBrush(Color.FromArgb(140, 255, 255, 255)), new RectangleF(10, 10, b.Width - 10, b.Height - 10), sformat);
        b.Save(context.Response.OutputStream, ImageFormat.Jpeg);
        b.Dispose();
    }

    #endregion
}

in .aspx page

 <div>
        <img src="salmankhan.jpg" />
    </div>


i hope you wiil Like this Blog


Ebook Download
View all
Learn
View all