using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebTask.Controllers
{
public class BarcodeImageController : Controller
{
//
// GET: /BarcodeImage/
public void ImageText()
{
try
{
Bitmap bitMapImage = new System.Drawing.Bitmap("E:\\Ananth\\coupon_popup.png");
Graphics graphicImage = Graphics.FromImage(bitMapImage);
//Smooth graphics is nice.
graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
//I am drawing a Rectangle around my text.
//graphicImage.DrawRectangle(new Pen(Color.Red, 3), 290, 915, 380, 50);
//Write your text.
graphicImage.DrawString("12F5B576B9E54B028B4D70DC7AD16376", new Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, new Point(310, 930));
//Set the content type
Response.ContentType = "image/jpeg";
bitMapImage.Save(@"E:\Ananth\BarcodeImage\test.jpeg", ImageFormat.Jpeg);
graphicImage.Dispose();
bitMapImage.Dispose();
}
catch (Exception ex)
{
string errormsg = ex.Message.ToString();
}
}
}
}Create a Text with in Image dynamically using C#.
