C#后台画图保存为ipg/png的文件
public void Exec1()
{
string imgurl = @"http://api.senwoo.com/Content/HeadPortrait/";
string imgurl = @"E:\";//本地头像路径-------
string imgfile = @"E:\";//图片路径-----------
//背景
Image image = new Bitmap(new Bitmap(imgfile + @"Img\d.jpg"), 720, 496);
#region 写字
Font font = new Font("微软雅黑", 11); //字是什么样子的?
Font font5 = new Font("微软雅黑", 9); //字是什么样子的?
Font font1 = new Font("微软雅黑", 8); //字是什么样子的? 兰亭特黑简.TTF
Font font2 = new Font("微软雅黑 粗体", 12); //字是什么样子的?
Brush brush = Brushes.Orange; //用红色涂上我的字吧; Orange
Brush white = Brushes.White;//白色的笔
#endregion
#region 获取数据库数据
DataSet ds = Getdateset();
DataTable tb = ds.Tables[0];
#endregion
#region 画图
Graphics g = null;
try
{
g = Graphics.FromImage(image);
}
catch (Exception e)
{
WriteLog(e.ToString());
throw;
}
int i = 0;
int num = 0;
int a1 = 41;//控制第(4-10)名的x坐标
int a2 = 36;//控制第(4-10)名的x坐标
int a3 = 47;//控制第(4-10)名的x坐标
int a4 = 65;//控制第(4-10)名的x坐标
int a5 = 65;
int x = 0; //第一 二 三 名的x坐标
foreach (DataRow item in tb.Rows)
{
Image i1 = new Bitmap(imgurl + @"Img\d2.jpg");//头像
if (Convert.ToInt32(item["D1"]) == 1)
{
//第一名
g.DrawImage(i1, 286, 112, 129, 129);
g.DrawImage(new Bitmap(imgfile + @"Img\2.png"), 279, 100, 145, 174);
g.DrawString(item["sdgroupname"].ToString(), font, white, 326, 227);
if (item["stname"].ToString().Length == 3)
{ x = 331; }
else
{ x = 317; }
g.DrawString(item["stname"].ToString(), font5, brush, x, 248);
}
else if (Convert.ToInt32(item["D1"]) == 2)
{
#region MyRegion
g.DrawImage(i1, 85, 139, 129, 129);
g.DrawImage(new Bitmap(imgfile + @"\img\3.png"), 79, 130, 145, 174);
if (item["sdgroupname"].ToString().Length == 3)
{
x = 126;
}
else
{
x = 119;
}
g.DrawString(item["sdgroupname"].ToString(), font, white, x, 256);
if (item["stname"].ToString().Length == 3)
x = 130;
else
x = 120;
g.DrawString(item["stname"].ToString(), font5, brush, x, 277);
#endregion
}
else if (Convert.ToInt32(item["D1"]) == 3)
{
#region MyRegion
WriteLog("开c3");
g.DrawImage(i1, 485, 139, 129, 129);
g.DrawImage(new Bitmap(imgfile + @"Img\5.png"), 479, 130, 145, 174);
if (item["sdgroupname"].ToString().Length == 3)
{
x = 523;
}
else
{
x = 535;
}
g.DrawString(item["sdgroupname"].ToString(), font, white, x, 256);
if (item["stname"].ToString().Length == 3)
x = 527;
else
x = 522;
g.DrawString(item["stname"].ToString(), font5, brush, x, 276);
#endregion
}
else
{
g.DrawImage(i1, a1 + num, 353, 79, 79);
g.DrawImage(new Bitmap(imgfile + @"Img\c.png"), a2 + num, 340, 92, 124);
if (i == 6)
{
a3 = a3 - 5;
}
g.DrawString((4 + i).ToString(), font2, white, a3 + num, 421);
g.DrawString(item["sdgroupname"].ToString(), font1, white, a4 + num, 423);
g.DrawString(item["stname"].ToString(), font1, brush, a5 + num, 438);
num += 92;
i++;
}
}
#endregion
WriteLog("开始保存");
#region MyRegion
//写好了,我要把我的作品收藏起来
try
{
g.BeginContainer();
string imgName = GetImgName();//原来的名字
string Route = "C:\\Program Files\\Apache Software Foundation\\Tomcat 7.0\\webapps\\Download\\Picture\\Operator\\";//服务器
Route = "E:\\Img\\";//本地路径
image.Save(Route + imgName);//保存在本地
string newImgName = Guid.NewGuid() + ".jpg";
//System.IO.File.Move(Route + imgName, Route + newImgName); //修改名称
//updateImgName(newImgName);
}
catch (Exception ex)
{
throw;
}
#endregion
WriteLog("完成");
}
C#后台画图保存为ipg/png的文件的更多相关文章
- 【故障公告】redis内存耗尽造成博客后台无法保存
非常抱歉,今天上午11:00~11:30左右,由于 redis 服务器内存耗尽造成博客后台故障--保存博文时总是提示"请求太过频繁,请稍后再试",由此给您带来麻烦,请您谅解. 由于 ...
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(32)-swfupload多文件上传[附源码]
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(32)-swfupload多文件上传[附源码] 文件上传这东西说到底有时候很痛,原来的asp.net服务器 ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(56)-插件---单文件上传与easyui使用fancybox
系列目录 https://yunpan.cn/cZVeSJ33XSHKZ 访问密码 0fc2 今天整合lightbox插件Fancybox1.3.4,发现1.3.4版本太老了.而目前easyui 1 ...
- 读取视屏文件,保存帧图片为ppm文件
ffmpeg跟sdl的学习过程:一.版本信息:ffmpeg-3.0.2.tar.bz2SDL2-2.0.4.tar.gz二.编译过程:1.ffmgeg的编译:./configure --enable- ...
- thinkphp 的两种建构模式 第一种一个单入口里面定义两个模块,前台和后台,函数控制模块必须function.php前台加载前台模块的汉书配置文件,后台加载后台模块的汉书配置文件,公共文件共用。第二种架构模式两个单入口文件,分别生成两个应用定义define。。。函数可以定义配置文件。。。。
thinkphp 的两种建构模式 第一种一个单入口里面定义两个模块,前台和后台,函数控制模块必须function.php前台加载前台模块的汉书配置文件,后台加载后台模块的汉书配置文件,公共文件共用. ...
- 读取.properties配置文件并保存到另一个.properties文件内
代码如下 import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileOutputSt ...
- 第三天,爬取伯乐在线文章代码,编写items.py,保存数据到本地json文件中
一. 爬取http://blog.jobbole.com/all-posts/中的所有文章 1. 编写jobbole.py简单代码 import scrapy from scrapy. ...
- tensorflow 保存训练模型ckpt 查看ckpt文件中的变量名和对应值
TensorFlow 模型保存与恢复 一个快速完整的教程,以保存和恢复Tensorflow模型. 在本教程中,我将会解释: TensorFlow模型是什么样的? 如何保存TensorFlow模型? 如 ...
- 以普通用户启动的Vim如何保存需要root权限的文件
在Linux上工作的朋友很可能遇到过这样一种情况,当你用Vim编辑完一个文件时,运行:wq保存退出,突然蹦出一个错误: E45: 'readonly' option is set (add ! to ...
随机推荐
- A1142. Maximal Clique
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the ...
- spring MVC 如何接收前台传入的JSON对象数组并处理
spring MVC 如何接收前台传入的JSON对象数组 主要方法: (主要用到的包是 net.sf.json 即:json-lib-2.3-jdk15.jar 完整相关jar包: commons- ...
- glob.glob 匹配文件
glob.glob以列表形式返回匹配的文件路径 只有一个参数:文件的匹配规则 e.g. >>>res_home = '/vip_data_center/test_envs/train ...
- (贪心)P1223 排队接水 洛谷
题目描述 有n个人在一个水龙头前排队接水,假如每个人接水的时间为Ti,请编程找出这n个人排队的一种顺序,使得n个人的平均等待时间最小. 输入输出格式 输入格式: 输入文件共两行,第一行为n:第二行分别 ...
- php调用API支付接口 转至http://www.cnblogs.com/chaochao00o/p/6490463.html
首先访问 https://charging.teegon.com/ 注册账号, 找到开发配置 记下client_id和client_secret. 点击 天工开放平台 点击天工收银 点击 S ...
- httprouter使用pprof
httprouter使用pprof 参考:https://github.com/feixiao/httpprof 性能分析参考:https://github.com/caibirdme/hand-to ...
- mysql 遍历所有的库并根据表和sql语句备份
建库.用户语句 create database test_hb; create user ' test_hb'@'%' identified by '123456'; grant all privil ...
- scrapy框架使用教程
scrapy框架真的是很强大.非常值得学习一下.本身py就追求简洁,所以本身代码量很少却能写出很强大的功能.对比java来说.不过py的语法有些操蛋,比如没有智能提示.动态语言的通病.我也刚学习不到1 ...
- nginx的rewrite指令
需求:我们在接收到一个/api/upload 开头的url的时候 要转发到另外一个地址.但是又不想追加/api/upload 只想追加/upload 地址. Nginx提供了rewrite指令,用于 ...
- vue基础篇---vue组件《2》
定义全局组件 我们通过Vue的component方法来定义一个全局组件. <div id="app"> <!--使用定义好的全局组件--> <coun ...