本文介绍了将ImageSharp.Image转换为ImageSharp.PixelFormats.Rgba32?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注一个教程( https://opentk.net/learn/chapter1/4-textures.html ).如何将类型"ImageSharp.Image"转换为"ImageSharp.PixelFormats.Rgba32"?

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);

但我不断收到错误消息: Cannot implicitly convert type 'SixLabors.ImageSharp.Image' to 'SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgba32>'. An explicit conversion exists (are you missing a cast?).

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?).

推荐答案

最新版本中的API更改.要显式获取Image<Rgba32>,然后调用Image.Load<Rgba32>(path).

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

但是,如果您不使用低级原始像素操作,则可能应该更改代码,而不是直接使用Image类作为其像素类型不可知类型,该类型支持所有内置突变而无需添加像素型杂讯.

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.

这篇关于将ImageSharp.Image转换为ImageSharp.PixelFormats.Rgba32?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 01:55