(资料图片)
当我们只知道图片byte[]数组的时候怎么知道这张图片的宽高尺寸?
答:转换的时候不要指定宽高,转的时候就会自动根据图片的实际宽高来转换了。直接上代码
public void ByteToImage(byte[] data) {
Texture2D texture2D = new Texture2D(0, 0);
texture2D.LoadImage(data);
Debug.Log("width="+texture2D.width + " height=" + texture2D.height);
}
输出效果如下:
标签: