[英]ImageSharp drawing shapes on image in Core 2.2
I am using ImageSharp
(ver 1.0.0-beta0006) in my .Net Core 2.2 project. 我在.Net Core 2.2项目中使用ImageSharp
(版本1.0.0-beta0006)。 I primarily use it to resize image (to generate thumbnail) and it's working fine. 我主要使用它来调整图像大小(以生成缩略图),并且工作正常。
Recently, I've got a requirement to draw rectangles on the image. 最近,我有一个要求在图像上绘制矩形。 Based on the documentation , this is what I've got to do: 根据文档 ,这是我要做的:
using (var image = new Image<Rgba32>(800, 800))
{
image.Mutate(x => x.DrawLines(
Rgba32.HotPink,
10,
new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(550, 50),
new Vector2(200, 400)
}));
using (var stream = new MemoryStream())
{
image.SaveAsBmp(stream);
}
}
However, I realize that in my Mutate
lambda methods there is not a method named DrawLines
. 但是,我意识到在我的Mutate
lambda方法中没有名为DrawLines
的方法。 Can I know if I'm missing an assembly? 我能知道我是否缺少大会吗? Based on the documentation, it is using
: 根据文档,它正在using
:
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.PixelFormats;
both of which are found in the SixLabors.ImageSharp
package. 两者都可以在SixLabors.ImageSharp
包中找到。
Install SixLabors.ImageSharp.Drawing
and you should be able to find the missing methods/extensions. 安装SixLabors.ImageSharp.Drawing
,您应该能够找到缺少的方法/扩展。
Image sharp is split into 2 main libraries, the main SixLabors.ImageSharp
which deals with the core image decoding/encoding and pixel pushing, then there is SixLabors.ImageSharp.Drawing
which handles various drawing sub systems, vector drawing, text rendering etc. 图像锐利分为两个主要库,主要的SixLabors.ImageSharp
处理核心图像解码/编码和像素推送,然后还有SixLabors.ImageSharp.Drawing
处理各种绘图子系统,矢量绘图,文本渲染等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.