I’m working on an app that downloads jpg image assets from outside of unity assets, store them in a texture2d array, and then display them on the screen, basically using an activity that lets user pick their photos store in sd card then send directory to unity to read and display. The problems is that they always get converted into rgb24 format when imported. rgb24 take up a huge amount of ram memory which is not good. So I need a way to read image file into a format that is more acceptable like etc4bits or dxt1…
I have tried using www and Texture2D.LoadImage() to load the texture into memory but both fail to work
string filePath = “android/path/to.jpg”;
WWW www = new WWW(filePath);
yield return www;
texList.Add(www.texture);
www.Dispose();
this imports the image file as rgb24 texture
Texture2D tex = new Texture2D(128,128,TextureFormat.DXT1, false);
tex.LoadImage(GetBytesFromFile(filePath)); //getbytesfromfile returns a byte[ ]
texList.Add(tex);
print(tex.format);
this actually works on pc, the texture width and height is replaced, but format remains as dxt1. but somehow it doesn’t work on android, the print(tex.format) statment prints dxt1 on pc but rpg24 on android
Any one have any idea on how to solve this issue. if runtime conversion to dxt1 format is not possible, then what about etc 4bit, I heard it is supported by android hardware. I’ve looked into some other post that addresses similar problem but none leads to an answer.
thanks