public void Exec1()
{
string imgurl = @"http://api.senwoo.com/Content/HeadPortrait/";
string imgurl = @"E:";//本地头像路径-------
string imgfile = @"E:";//图片路径-----------
//背景
Image image = new Bitmap(new Bitmap(imgfile + @"Imgd.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 + @"Imgd2.jpg");//头像
if (Convert.ToInt32(item["D1"]) == 1)
{
//第一名
g.DrawImage(i1, 286, 112, 129, 129);
g.DrawImage(new Bitmap(imgfile + @"Img2.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 + @"img3.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 + @"Img5.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 + @"Imgc.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("完成");
}