Add text to Image in ASP.NET

Sometimes, it is nice to have a text caption embedded into an image, rather than
display the caption in HTML. Fortunately, this is fairly straightforward in ASP.NET.

You can embed some text into the photo:


Play around with the querystring. See how the caption changes when you
change the text in the querystring.

Here is the code for image_text.aspx

<%@ Page Language="c#"%>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %> 
<script runat="server">
	private void Page_Load(object sender, System.EventArgs e)
		Bitmap bmp= new Bitmap(Server.MapPath(Request.QueryString["i"]));
		Graphics g=Graphics.FromImage(bmp);
		g.SmoothingMode = SmoothingMode.AntiAlias ;
			new Font("verdana",12),SystemBrushes.WindowText, 1, 1);
		bmp.Save(Response.OutputStream, bmp.RawFormat) ;
Updated: March 6, 2015 — 5:26 pm


Add a Comment
  1. Your comment is awaiting moderation.

    Nicely put, Thank you.
    canadian prescription drugs
    north west pharmacy canada
    no prescription online pharmacy
    canadian cialis

  2. Your comment is awaiting moderation.

    Really a good deal of terrific advice.
    best online pharmacies no prescription canada pharmacy canadian online pharmacies london drugs canada
    canadian drugstore reviews
    pharmacies in canada
    pharmacy canada
    canadian drugstore

Leave a Reply

Your email address will not be published. Required fields are marked *