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,好的謝謝。 –