Archive

Archive for January, 2011

Add watermark to an image using C#

January 18th, 2011 2 comments

Below is the sample. I call it ShowImage.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
 
<script runat="server">
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["image"] == null) return;
        string WatermarkImg = 
              Server.MapPath(@"images\watermark.png");
        string CarImg = 
              Server.MapPath(Request.QueryString["image"]);
 
        Bitmap bmp = new Bitmap(CarImg);
 
        Graphics g = Graphics.FromImage(bmp);
 
        g.SmoothingMode = SmoothingMode.HighQuality;
 
        Bitmap bmpWM = (Bitmap)Bitmap.FromFile(WatermarkImg);
 
        g.DrawImage(bmpWM, new Point(bmp.Width-bmpWM.Width,
                    bmp.Height-bmpWM.Height) );
 
        bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
        bmp.Dispose();
        bmpWM.Dispose();
        g.Flush();
    }
</script>

You can call this using:

<asp:Image ID="Image4" runat="server" ImageUrl
     ="~/ShowImage.aspx?image=images\cadillac_thumb.jpg" />
<img src="ShowImage.aspx?image=images\pagani.jpg" />
VN:F [1.9.18_1163]
Rating: 3.3/5 (7 votes cast)
Categories: ASP.NET, C#

ASP.NET MVC 3 RTM Released

January 17th, 2011 No comments

The ASP.NET team has released RTM version of ASP.NET MVC 3. You can download the ASP.NET MVC 3 RTM from here . Microsoft has released the following products along with ASP.NET MVC 3.

  • NuGet
  • IIS Express 7.5
  • SQL Server Compact Edition 4
  • Web Deploy and Web Farm Framework 2.0
  • Orchard 1.0
  • WebMatrix 1.0 
VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
Categories: ASP.NET