27 Star 68 Fork 16

闭包客 / Less.Image

加入 Gitee
与超过 800 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Program.cs 1.61 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
闭包客 提交于 2017-11-17 16:02 . 修改 ToImage 方法
using Less.Image;
using Less.Windows;
using System.Drawing;
namespace Test
{
class Program
{
static void Main(string[] args)
{
string file = Application.SetupDir.CombinePath("yangmi.jpg");
Image origin = Image.FromFile(file);
//test1
Image test1 = origin.Resize(300, 200);
test1.Save(Application.SetupDir.CombinePath("yangmi_300_200.jpg"), 90);
//test2
Image test2 = origin.Resize(300, 200, ResizeMode.WidthFirst);
test2.Save(Application.SetupDir.CombinePath("yangmi_300_200_WidthFirst.jpg"), 90);
//test3
Image test3 = origin.Crop(180, 180);
test3.Save(Application.SetupDir.CombinePath("yangmi_180_180.jpg"), 90);
//test4
Image test4 = origin.ResizeW(300);
test4.Save(Application.SetupDir.CombinePath("yangmi_W300.jpg"), 90);
//test5
Image test5 = origin.ResizeH(200);
test5.Save(Application.SetupDir.CombinePath("yangmi_H200.jpg"), 90);
//
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
"Q".ToImage(
32, 32, Color.White, new Font("Arial", 21), Brushes.Black, new RectangleF(0, 0, 32, 32), format).Save(
Application.SetupDir.CombinePath("Q.jpg"));
"天".ToImage(
32, 32, Color.White, new Font("微软雅黑", 17), Brushes.Black, new RectangleF(0, 0, 32, 32), format).Save(
Application.SetupDir.CombinePath("天.jpg"));
}
}
}
C#
1
https://gitee.com/bibaoke/Less.Image.git
git@gitee.com:bibaoke/Less.Image.git
bibaoke
Less.Image
Less.Image
master

搜索帮助