zoukankan      html  css  js  c++  java
  • 把二维码的图片和文字结合到一个背景图片上,合成一张图

            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");  //返回浏览器图片文件
                }
            }
    图片合成
  • 相关阅读:
    react 组件间通信,父子间通信
    微信公众号配置及微信jsAPI支付
    Vue 幸运大转盘
    Hystrix断路器配置属性解析
    使用熔断器仪表盘监控(hystrix)
    使用熔断器防止服务雪崩
    创建服务消费者(Feign)
    Spring Cloud Ribbon配置详解
    创建服务消费者(Ribbon)
    创建服务提供者
  • 原文地址:https://www.cnblogs.com/qq605490312/p/7110264.html
Copyright © 2011-2022 走看看