Convert ImageSharp.Image to ImageSharp.PixelFormats.Rgba32?

回眸只為那壹抹淺笑 提交于 2020-01-24 09:38:09

问题


I am following a tutorial (https://opentk.net/learn/chapter1/4-textures.html) using ImageSharp. How do I convert the type 'ImageSharp.Image' to 'ImageSharp.PixelFormats.Rgba32'?

To load the Image, I am using

Image<Rgba32> image = Image.Load(path);

but I keep getting the error: Cannot implicitly convert type 'SixLabors.ImageSharp.Image' to 'SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgba32>'. An explicit conversion exists (are you missing a cast?).


回答1:


The API change in the latest release. To explicitly get an Image<Rgba32> then call Image.Load<Rgba32>(path) instead.

However if you aren't working with low level raw pixel manipulation then you should probably just change your code instead to use the Image class directly as its a pixel type agnostic type that supports all the built in mutations without the added pixel type noise.



来源:https://stackoverflow.com/questions/57789399/convert-imagesharp-image-to-imagesharp-pixelformats-rgba32

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!