我想从图像文件中获取数据并在 Unity 可以读取的纹理中显示该信息。
我能够将像素信息放入字节数组中,但屏幕上没有任何显示。我如何真正让图像显示?
pcxFile = File.ReadAllBytes("Assets/5_ImageParser/bagit_icon.pcx");
int startPoint = 128;
int height = 152;
int width = 152;
target = new Texture2D(height, width);
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
timesDone ++;
pixels[x, y] = new Color(pcxFile[startPoint], pcxFile[startPoint+1], pcxFile[startPoint+2]);
startPoint += 4;
target.SetPixel(x, y, pixels[x, y]);
}
}
target.Apply();
target.EncodeToJPG();
HUH函数
相关分类