'How to reverse channel order of a Texture2D unity
I need to convert a texture2D from having the normal RGBA channel order to BGRA channel order. I was originally hoping it would be as easy as
// Load image
Texture2D loaded = Resources.Load("zidane_640x640") as Texture2D;
// Convert from RGBA32 to BGRA32
Texture2D frame = new Texture2D(loaded.height, loaded.width, TextureFormat.BGRA32, false);
frame.SetPixels32(loaded.GetPixels32());
frame.Apply();
But that has no effect. I can't find a method anywhere to just switch the channel order for either Color[] or Texture2D. Is there any easy way to do this, or do I have to manually swap the channel order pixel by pixel?
Solution 1:[1]
It works fine. You just made a typo there.
Texture2D frame = new Texture2D(loaded.width, loaded.height, TextureFormat.BGRA32, false);
Alternatively:
Graphics.ConvertTexture( src , dst );
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrew ?ukasik |
