dongwuqi4243
2017-11-28 15:42
浏览 607
已采纳

将图像从* image.YCbCr转换为* image.RGBA

I am loading a jpeg from the disk, and I would like to do some RGBA operations on it.

However, since the jpeg is not RGBA, i get an error when I try to use it as such:

thumbnail,err:=jpeg.Decode(imageAsReader)
...
return thumbnail.(*image.RGBA)

yeileds the error:

interface conversion: image.Image is *image.YCbCr, not *image.RGBA

Is there an easy way to convert the image to RGBA once I have loaded it in memory? (Other operations are in RGBA later on, so that is the color model I want to use in memory).

图片转代码服务由CSDN问答提供 功能建议

我正在从磁盘加载jpeg,并且我想对其进行一些RGBA操作。</ p >

但是,由于jpeg不是RGBA,因此当我尝试使用jpeg时出现错误:</ p>

  thumbnail,err:= jpeg 解码(imageAsReader)
 ... 
返回缩略图。(* image.RGBA)
 </ code> </ pre> 
 
 

出现错误:</ p> < pre> 接口转换:image.Image是* image.YCbCr,而不是* image.RGBA </ code> </ pre>

是否有一种简单的方法可以将图像转换为RGBA 一旦我将其加载到内存中? (其他操作稍后将在RGBA中进行,所以这是我要在内存中使用的颜色模型。)</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题