标签:style blog color io os ar for div on
public void InitPage(string url, UserInfoBusinessCardView model) { string path = Path.GetDirectoryName(url); string filename = DateTime.Now.ToString("yyyyMMddhhmmss"); using (Image bigImage = Image.FromFile(url)) { using (Image smallImg = Image.FromFile(model.HeadPhotos)) { using (Graphics g = Graphics.FromImage(bigImage)) { int x = bigImage.Width - smallImg.Width; int y = bigImage.Height - smallImg.Height; //添加头像 g.DrawImage(smallImg, 0, 0, smallImg.Width, smallImg.Height); SolidBrush drawBush = new SolidBrush(Color.Red); Font drawFont = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Millimeter); string newPath = path + "\\" + filename + ".png"; //写汉字 g.DrawString(model.Name, drawFont, drawBush, 10, 10); g.DrawString(model.Title1String + model.Title2String, drawFont, drawBush, 50, 50); bigImage.Save(newPath, System.Drawing.Imaging.ImageFormat.Png); if (System.IO.File.Exists(newPath)) { //return newPath; } else { // return null; } } } } }
//调用的地方
public ActionResult PPP() { string url = Request.MapPath("~/Images/4560.jpg"); string heda = Request.MapPath("~/Images/745.jpg"); UserInfoBusinessCardView model = new UserInfoBusinessCardView(); model.Name = "刘建伟"; model.Title1String = "XXXXXXXXX牛逼公司"; model.Title2String = "码农"; model.HeadPhotos = heda; InitPage(url, model); return View(); }
///
标签:style blog color io os ar for div on
原文地址:http://www.cnblogs.com/alphafly/p/4037409.html