tuimg image project. tuimg 是一个专注于操作、读取、生成图片 的解决方案。
$ dotnet add package tuimgtuimg 是一个专注于操作、读取、生成图片 的解决方案。
var newbmp = new TuimgBmp(300, 300);
using (var b = newbmp.Scale(0.5f).ToStream())
using (var f = File.Create("a.bmp")) b.CopyTo(f);
var png = new TuimgPng(100,100);
using (var s= png.ToStream())
using (var f = File.Create("a.png")) s.CopyTo(f);
var img = new TuimgIco("shared.ico");
using (var s = img.ToStream())
using (var f = File.Create("a.ico")) s.CopyTo(f);
// create new
var png = new TuimgPng("a.png");
var icon2 = new TuimgIco();
icon2.InsertBmp(png);
icon2.ToStream(File.Create("sss.ico"));
路径
using (var mifont = new TuimgFont("MiSans-Regular.ttf"))
var path = mifont.ReadPath(i);
颜色
public static TuimgColor FromRgb(byte r, byte g, byte b)
字体
// can change png.
// var newimg = new TuimgPng(300, 300);
var newimg = new TuimgBmp(300, 300);
using (var mifont = new TuimgFont("MiSans-Regular.ttf"))
{
var g = new TuimgGrid(300, 300);
var x = 30;
foreach (var i in "A13")
{
if (i != ' ')
{
var path = mifont.ReadPath(i);
var g1 = path.ToGrid_ScaleHeight(72);
g.BottomCross(g1, x);
x += g1.Width;
}
x += 2;
}
newimg.DrawGrid(62, 10, g.CopyTrim());
}
using (var b = newimg.ToStream())
using (var f = File.Create("a.bmp")) b.CopyTo(f);
栅格
public void On(int x, int y)
public void Off(int x, int y)
public bool Read(int x, int y)
public void Clear()
public void Reverse()
public void Cross(TuimgGrid g)
public void CopyTo(TuimgGrid g)
public void Fill(int x, int y)
public void DrawCurve(int x1, int y1, int x2, int y2, int cx1, int cy1)
public void DrawLine(int x1, int y1, int x2, int y2)
public void DrawPath(int x, int y, TuimgPath path, int scale)
// 删除两侧空白
public TuimgGrid CopyTrim()