I am trying to create new instance of Image class with SixLabors.Imagesharp but I got error. The system I work with used the old ImageSharp and We want to renew nuget packages and use SixLabors.ImageSharp instead.
The code used to be like this: OLD Code with ImageSharp:
var resultImage = new Image<Rgba32>(outputImageWidth, outputImageHeight);
The new code I try to write with SixLabors.ImageSharp is exactly the same but this time I got the massage:
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 '?'.
I tried a lot of other ways to create a new Image but I failed. Do you have any idea how I can create new Image using SixLabors.Imagesharp?
The namespace for the pixel format has changed so your code is missing an import.
using SixLabors.ImageSharp.PixelFormats;
The following code compiles and runs for 1.0.0-rc0001
using (var image = new Image<Rgba32>(1000, 1000))
{
// Do something
}
Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With