问题描述
我目前正在将 C# 库“ImageSharp”用于 .NET Core 中的某些内容,我想知道是否可以使用它对某些文本应用“内斜角”效果。我已经将我在单独的图形应用程序中创建的示例图像放在一起,以演示我想要实现的目标。它看起来像您在书籍封面上看到的凸起字母,在我的图形应用程序中,它被称为“内斜角”效果。 ImageSharp 可以做到这一点吗?如果没有,是否有其他 C# 图像处理库可以做到这一点?
这是我目前编写的用于创建文本的方法:
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.PixelFormats;
public static void CreateTextPng(string SavePath,int Width,string Text)
{
var TheFont = new Font(SystemFonts.Find("Times New Roman"),40,FontStyle.Bold);
var Size = TextMeasurer.Measure(Text,new RendererOptions(TheFont) { WrappingWidth = Width });
using (var TheImage = new Image<Rgba32>(Width,(int)Math.Round(Size.Height)))
{
TheImage.Mutate(delegate (IImageProcessingContext Processor)
{
var textGraphicsOptions = new TextGraphicsOptions(new GraphicsOptions(),new TextOptions
{
HorizontalAlignment = HorizontalAlignment.Center,VerticalAlignment = VerticalAlignment.Center,WrapTextWidth = TheImage.Width
});
Processor.DrawText(textGraphicsOptions,Text,TheFont,Color.Yellow,new PointF(0,TheImage.Height / 2));
//
//I think this is where the code to create the "inner bevel" effect would go,but I don't know what to put here...
//
});
TheImage.SaveAsPng(SavePath,new PngEncoder { CompressionLevel = PngCompressionLevel.BestCompression });
}
}
这里是方法调用:
CreateTextPng("C:/dev/textexample.png",400,"Good Omens: The Nice and Accurate Prophecies of Agnes Nutter,Witch");
这种斜角效果完全可以用 ImageSharp 完成吗?任何帮助将不胜感激!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)