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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Muhammad younas
NA
169
483.1k
store image in a variable
Aug 16 2012 3:51 AM
hi
i want to store image in a variable from folder. is it possible.
actually i m editing an image using bitmap image. i m writing text on it. it is working fine . now i want to add a small picture on that image. can anyone help me?
this is my code
string cs = System.Configuration.ConfigurationManager.ConnectionStrings["cmsCS"].ConnectionString;
System.Data.SqlClient.SqlConnection sqlconn = new System.Data.SqlClient.SqlConnection(cs);
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter();
System.Data.DataTable dt = new System.Data.DataTable();
da.SelectCommand = new System.Data.SqlClient.SqlCommand("SELECT StudentName ,FatherName, CourseStartDate,CourseEndDate,Percentage,Grade,TestName,TestDate,TranscriptId,Certificate,CourseId FROM RegularStudents WHERE (RegistrationNo = '" + username + "')", sqlconn);
sqlconn.Open();
da.Fill(dt);
sqlconn.Close();
string coursid=dt.Rows[0][10].ToString();
System.Data.SqlClient.SqlDataAdapter da1 = new System.Data.SqlClient.SqlDataAdapter();
System.Data.DataTable dt1 = new System.Data.DataTable();
da1.SelectCommand = new System.Data.SqlClient.SqlCommand("SELECT contents FROM Contents WHERE CourseId='"+ coursid +"'",sqlconn);
da1.Fill(dt1);
int i = 0;
// foreach (System.Data.DataRow dr in dt.Rows)
{
//SqlCommand cmd = new SqlCommand("", sqlconn);
name = dt.Rows[0][0].ToString();
fname=dt.Rows[0][1].ToString();
//string formate = "DD MM,YYYY";
coursestrtdat = dt.Rows[0][2].ToString() ;
coursestrtdat = coursestrtdat.Replace("/", "-");
string mnth = coursestrtdat.Substring(0, 2);
string datt = coursestrtdat.Substring(3, 2);
string year = coursestrtdat.Substring(6);
coursestrtdat = datt + "-" + mnth + "-" + year;
courseenddate =dt.Rows[0][3].ToString();
courseenddate = courseenddate.Replace("/", "-");
string mnth1 = courseenddate.Substring(0, 2);
string datt1 = courseenddate.Substring(3, 2);
string year1 = courseenddate.Substring(6);
courseenddate = datt1 + "-" + mnth1 + "-" + year1;
percnt =dt.Rows[0][4].ToString();
grade =dt.Rows[0][5].ToString();
registration = username;
trid = dt.Rows[0][8].ToString();
testdt = dt.Rows[0][7].ToString();
testname = dt.Rows[0][6].ToString();
string certf=dt.Rows[0][9].ToString();
string path = "";
if (certf == "Certificate")
{
path = "regularcertificate.jpg";
}
else
{
path = "Regular Diploma.jpg";
}
name = name.ToUpper();
//courseenddate = courseenddate.ToString(formate);
System.Drawing.Bitmap bitMapImage = new System.Drawing.Bitmap(Server.MapPath("images\\"+path));
System.Drawing.Graphics graphicImage = System.Drawing.Graphics.FromImage(bitMapImage);
int count = name.Length;
int count1 = testname.Length;
int j = 330;
foreach (System.Data.DataRow dtr in dt1.Rows)
{
string content = dtr[0].ToString();
content="* " + content;
i++;
graphicImage.DrawString(content, new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Regular), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(1150, j));
j = j + 40;
}
percnt = percnt + " %";
graphicImage.DrawString(name, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(420, 515));
graphicImage.DrawString(fname, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(420, 590));
graphicImage.DrawString(coursestrtdat, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(625, 664));
graphicImage.DrawString(courseenddate, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(900, 664));
graphicImage.DrawString(percnt, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(215, 744));
graphicImage.DrawString(grade, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(695, 744));
graphicImage.DrawString(testdt, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(899, 742));
graphicImage.DrawString(testname, new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(1250, 210));
graphicImage.DrawString(registration, new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(1300, 85));
graphicImage.DrawString(trid, new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(1300, 950));
graphicImage.DrawString("Transcript ID.-------------------------------------", new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Italic), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(1140, 960));
//graphicImage.DrawImage(graphicImg, 200, 200);
// graphicImage.DrawString(testname, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold), System.Drawing.SystemBrushes.WindowText, new System.Drawing.PointF(410, 320));
Response.ContentType = "image/jpeg";
bitMapImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
//bitMapImage.Save("bitmaptest.jpg", ImageFormat.Jpeg);
graphicImage.Dispose();
bitMapImage.Dispose();
Reply
Answers (
2
)
how to convert an object from json format to integer format
Pivot Result Display