我正在为一个图像添加字幕,但是对于像M和W这样的字母来说角落太尖锐了.
有圆角的方法吗?
这是我目前的方法.由于我在WPF中使用它,因此它有很长的引用,我不希望它发生冲突.
public static System.Drawing.Image captionImage(System.Drawing.Image img,string text,string font,float fontSize,int left,int top) { System.Drawing.FontFamily c; c = System.Drawing.FontFamily.Families.Where(x => x.Name.ToLower() == font.ToLower()).First(); if (c != null) { using (System.Drawing.StringFormat sf = new System.Drawing.StringFormat()) { sf.Alignment = System.Drawing.Stringalignment.Near; sf.LineAlignment = System.Drawing.Stringalignment.Near; using (system.drawing.graphics g = system.drawing.graphics.FromImage(img)) { using (System.Drawing.drawing2d.GraphicsPath path = new System.Drawing.drawing2d.GraphicsPath()) { path.AddString(text,c,fontSize,new System.Drawing.Point(left,top),sf); g.SmoothingMode = System.Drawing.drawing2d.SmoothingMode.AntiAlias; g.DrawPath(new System.Drawing.Pen(System.Drawing.Color.Black,fontSize * 0.3f),path); g.FillPath(System.Drawing.Brushes.White,path); } } } } return img; }
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。