TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Dynamically Create a Text on Image
Ananth Ananthakrishnan
Nov 04
2014
Code
2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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();
}
}
}
}
C#
Asp.net
Asp.net MVC