PS:这里简单解释一下为什么文字中心是 (x1 + sf.Width / 2, y1 + sf.Height / 2) ,因为 (x, y) 是左上角,而 sf.Width 、 sf.Height 是文字矩形区域宽、高。如图:

测试调用
private static void Main(string[] args)
{
try
{
Console.WriteLine("Start drawing ...");
DrawingEntity drawing = new DrawingEntity();
System.Drawing.Bitmap bmp = drawing.AddText(@"D:test1.png", "176.94,150.48", 66, "写点啥好呢", 30);
bmp.Save(@"D:testoutput.png");
bmp.Dispose();
Console.WriteLine("Done!");
}
catch (System.Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
System.Console.WriteLine("nPress any key to continue ...");
System.Console.ReadKey();
}
}
最终效果
没有旋转时

中心旋转30度

总结
以上所述是小编给大家介绍的C# 使用 GDI+ 实现添加中心旋转(任意角度)的文字,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对ASPKU网站的支持!
注:相关教程知识阅读请移步到c#教程频道。










