把二维码的图片和文字结合到一个背景图片上,合成一张图

        public ActionResult HeCheng(string name)
        {
            string imgFullPath = HttpContext.Server.MapPath("~/images/djq_bg.jpg");
            string imgFullPathwx = HttpContext.Server.MapPath("~/images/wx_bg.jpg");
            using(Image bmp = Bitmap.FromFile(imgFullPath))//读取一种已有的图片
            using (Image bmpwx = Bitmap.FromFile(imgFullPathwx))//读取一种已有的图片
            using(Graphics g = Graphics.FromImage(bmp))//得到图片的画布
            using(Font font1 = new Font(FontFamily.GenericSansSerif,10))
            {
                g.DrawImage(bmpwx, 72, 850);
                g.DrawString(name, font1, Brushes.Red, 155, 595);
                MemoryStream ms = new MemoryStream();
                string path = "/upload/" + DateTime.Now.ToString("yyyy/MM/dd") + "/" + System.Guid.NewGuid().ToString("N") + ".jpg";// /upload/2017/07/03/d824e21d203f42f2ab3217d230cf8aea.jpg
                string fullPath = HttpContext.Server.MapPath("~" + path);//d://22/upload/2017/07/03/d824e21d203f42f2ab3217d230cf8aea.jpg
                new FileInfo(fullPath).Directory.Create();//尝试创建可能不存在的文件夹
                bmp.Save(fullPath);//保存到服务器的硬盘上
           
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                return File(ms.ToArray(), "image/jpeg");  //返回浏览器图片文件
            }
        }
图片合成
原文地址:https://www.cnblogs.com/qq605490312/p/7110264.html