1
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Test1 : MonoBehaviour {
public int textureWidth = 400;
public int textureHeight = 400;
public RawImage textureDisplayer;
void Start()
{
string imageUrl = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
StartCoroutine(LoadImg(imageUrl));
}
void displayImage(Texture2D imgToDisp)
{
//Resize Image
textureDisplayer.GetComponent<RectTransform>().sizeDelta = new Vector2(textureWidth, textureHeight);
textureDisplayer.texture = imgToDisp;
byte[] bytes = imgToDisp.EncodeToPNG();
System.IO.File.WriteAllBytes("image", bytes);
}
IEnumerator LoadImg(string url)
{
yield return null;
WWW www = new WWW(url);
yield return www;
displayImage(www.texture);
}
}
这里我试图将impToDisp保存到我的手机内存。我的代码中的 我可以加载图像。如何将图像保存为统一的手机内存(Android手机)
我需要的是加载图像保存到我的手机memory.how我能做到这一点
您好,欢迎SO。请在您的答案中包含引用代码的片段,因此即使链接网站脱机(不太可能)的情况下,答案也可以单独使用。 – RasmusW
@RasmusW,好的谢谢。 –