using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
public RawImage leftImage;
private string path = "\\Assets\\StreamingAssets\\001.jpg";
WWW w;
public byte[] FunTurnTo(string path)
{
FileStream fileStream = new FileStream(path, FileMode.Open, System.IO.FileAccess.Read);
fileStream.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[fileStream.Length];
fileStream.Read(buffer, 0, (int)fileStream.Length);
fileStream.Close();
fileStream.Dispose();
fileStream = null;
print(456);
return buffer;
}
public void PicToByteArray()
{
byte[] bear = FunTurnTo(System.Environment.CurrentDirectory + path);
FileStream fs = new FileStream(System.Environment.CurrentDirectory + "\\Assets\\StreamingAssets\\666.jpg", FileMode.Create, FileAccess.Write);
fs.Write(bear, 0, bear.Length);
fs.Close();
StartCoroutine(LoadPicOfStreamingAssets());
leftImage.texture = w.texture;
print(123);
}
IEnumerator LoadPicOfStreamingAssets()
{
w = new WWW(System.Environment.CurrentDirectory + "\\Assets\\StreamingAssets\\666.jpg");
return w;
}
}