C#在模板图片写字,绘图

论坛 期权论坛 脚本     
匿名网站用户   2020-12-20 17:48   103   0
#region 打印图片


public bool printpicture(string ID)
{
bool res = false;
MExaminee = BExaminee.GetModel(Convert.ToInt32(ID));
if (MExaminee != null)
{
try
{
Bitmap bp = new Bitmap(Server.MapPath("../images/") + "tzs.jpg");
Bitmap photo = new Bitmap(Server.MapPath("../StuPic/") + MExaminee.TestNum.Trim() + ".JPG");
using (Graphics g = Graphics.FromImage(bp))
{
g.DrawString(MExaminee.Name, new System.Drawing.Font("华文楷体", 16),
Brushes.Black, new PointF(570, 865));
g.DrawString(MExaminee.Department + " " + MExaminee.Profession, new System.Drawing.Font("华文楷体", 16),
Brushes.Black, new PointF(670, 1165));
g.DrawString("2016 6", new System.Drawing.Font("华文楷体", 16),
Brushes.Black, new PointF(2100, 1725));
g.DrawImage(photo, 2322, 370, 370, 450);


Code.BarCode.Code128 _Code = new Code.BarCode.Code128();
Bitmap imgTemp = _Code.GetCodeImage(MExaminee.TestNum.Trim(), Code.BarCode.Code128.Encode.Code128C);
g.DrawImage(imgTemp, 2332, 830, 350, 80);


g.Flush();
imgTemp.Dispose();
}
string ImgUrl = Server.MapPath("../Photo/") + MExaminee.Department.Trim() + "_" + MExaminee.TestNum.Trim() + "_" + MExaminee.Name.Trim() + ".jpg";
if (System.IO.File.Exists(ImgUrl))
{
System.IO.File.Delete(ImgUrl);
}
bp.Save(ImgUrl);
bp.Dispose();
photo.Dispose();
MExaminee.Status = 1;//默认0,未处理;1,处理;2,处理出错;
BExaminee.Update(MExaminee);
res = true;
}
catch (Exception ex)
{
MExaminee.Status = 2;
BExaminee.Update(MExaminee);
res = false;
}


}
return res;
}
#endregion
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP