unity 图片转byte数组

有任何问题可以添加 QQ群 207019099

public static byte[] ReadTexture(string path)
    {
        Debug.Log(" @ ! the texture path is + !!    " + path);
        FileStream fileStream = new FileStream(path, FileMode.Open, System.IO.FileAccess.Read);

        fileStream.Seek(0, SeekOrigin.Begin);

        byte[] buffer = new byte[fileStream.Length]; //创建文件长度的buffer   
        fileStream.Read(buffer, 0, (int)fileStream.Length);

        fileStream.Close();

        fileStream.Dispose();

        fileStream = null;

        return buffer;
    }

你可能感兴趣的:(常用库)