Commit d6fb6d7f authored by 黄奎's avatar 黄奎

生成图片测试

parent d5ab13b9
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -11,9 +13,58 @@ namespace Test
static void Main(string[] args)
{
Console.WriteLine("Start......");
Helper.FreightRulesHelper.GetData();
//Helper.FreightRulesHelper.GetData();
//Test();
Console.WriteLine("End......");
Console.ReadLine();
}
public class FileModel
{
public int Id { get; set; }
public string FilePath { get; set; }
}
public static void Test()
{
//获取到pic下面的jpg图片
List<FileModel> fileList = new List<FileModel>();
string[] rs = System.IO.Directory.GetFiles(@"C:\Users\qiaoyajun\Desktop\ppt", "*.png");
foreach (var item in rs)
{
var fileName = System.IO.Path.GetFileNameWithoutExtension(item);
Int32.TryParse(fileName, out int FileNum);
var fileModel = new FileModel()
{
Id = FileNum,
FilePath = item
};
fileList.Add(fileModel);
}
var newFileList = fileList.OrderBy(qitem => qitem.Id).ToList();
//最大宽度和高度
int maL = 959, totalH = 18292;
Bitmap map = new Bitmap(maL, totalH);//定义画布
Graphics g = Graphics.FromImage(map);//定义画笔
g.Clear(Color.White);//把画布更改为白色
int y = 0;//y轴坐标
for (int i = 0; i < newFileList.Count; i++)
{
Image image = Image.FromStream(new System.IO.MemoryStream(File.ReadAllBytes(newFileList[i].FilePath)));
g.DrawImage(image, new Point(0, y));
y = y + 538;//y的告诉 5是为了让画布有个缝隙
}
//把合并的图片进行保存为jpg格式
map.Save(@"C:\Users\qiaoyajun\Desktop\HK\1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
for (int i = 0; i < rs.Length; i++)
{
//删除原先的2个jpg图片
//File.Delete(rs[i]);
}
}
}
}
......@@ -58,6 +58,7 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment