我正在尝试使用 SixLabors.Imagesharp 创建 Image 类的新实例,但出现错误。我使用的系统使用了旧的 ImageSharp,我们想更新 nuget 包并改用 SixLabors.ImageSharp。
以前的代码是这样的: OLD Code with ImageSharp:
var resultImage = new Image<Rgba32>(outputImageWidth, outputImageHeight);
我尝试用 SixLabors.ImageSharp 编写的新代码完全相同,但这次我得到了按摩:
Severity Code Description Project File Linem Suppression State
Error CS0315 The type 'SixLabors.ImageSharp.PixelFormats.Rgba32' cannot be used as type parameter 'TPixel' in the generic type or method 'Image<TPixel>'. There is no boxing conversion from 'SixLabors.ImageSharp.PixelFormats.Rgba32' to '?'.
我尝试了很多其他方法来创建新图像,但都失败了。您知道如何使用 SixLabors.Imagesharp 创建新图像吗?