【发布时间】:2020-11-22 11:36:21
【问题描述】:
我一直在尝试将格式从在 Alpha8 中提供纹理的相机更改为 RGBA,但到目前为止没有成功。
这是我尝试过的代码:
public static class TextureHelperClass
{
public static Texture2D ChangeFormat(this Texture2D oldTexture, TextureFormat newFormat)
{
//Create new empty Texture
Texture2D newTex = new Texture2D(2, 2, newFormat, false);
//Copy old texture pixels into new one
newTex.SetPixels(oldTexture.GetPixels());
//Apply
newTex.Apply();
return newTex;
}
}
我这样调用代码:
Texture imgTexture = Aplpha8Texture.ChangeFormat(TextureFormat.RGBA32);
但图像已损坏且不可见。
有谁知道如何将此 Alpha8 更改为 RGBA 以便我可以像处理 OpenCV 中的任何其他图像一样处理它?
【问题讨论】: