简体   繁体   English

Core 2.2中ImageSharp在图像上绘制形状

[英]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.

相关问题 在.NET Core 2.2下的System.Drawing中找不到Image类 - Can't find Image class in System.Drawing under .NET Core 2.2 使用ImageSharp放置旋转的图像 - Placing a rotated image with ImageSharp 使用.NET Core 2.2上传图像 - Upload an Image with .NET Core 2.2 加载图像,通过单击按钮在其上绘制形状,通过鼠标在其上绘制线条 - loading an image,drawing shapes on it by clicking a button,drawing lines on it by mouse Asp.Net Core:使用 ImageSharp 压缩图像并使用 Blob 保存到数据库 - Asp.Net Core : Compress the image using ImageSharp and save to database using Blob ImageSharp.Web - 在 Asp.Net Core 3.1 中通过查询字符串调整图像大小 - ImageSharp.Web - resize image by querystring in Asp.Net Core 3.1 ImageSharp:绘制一个剪裁的多边形越界 - ImageSharp: Drawing a clipped Polygon out of bounds 使用 ImageSharp 缩小图像文件 - Shrink image file using ImageSharp 使用 ImageJ 或 ImageJ 在线查看的 C# 库无法查看图像已尝试 ImageMagick 和 ImageSharp 和 System.Drawing - Image not viewable using C# libraries viewable in ImageJ or ImageJ online have tried ImageMagick and ImageSharp and System.Drawing 将 ImageSharp.Image 转换为 ImageSharp.PixelFormats.Rgba32? - Convert ImageSharp.Image to ImageSharp.PixelFormats.Rgba32?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM