纳金网
标题:
获取屏幕中指定的像素并存储为png图片格式
[打印本页]
作者:
狂风大尉
时间:
2014-11-30 08:44
标题:
获取屏幕中指定的像素并存储为png图片格式
public void Start () {
StartCoroutine(CaptureScreen());
}
IEnumerator CaptureScreen () {
yield return new WaitForEndOfFrame();
float width = Screen.width;
float height = Screen.height;
Texture2D tex = new Texture2D (width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels (Rect(0, 0, width, height), 0, 0);
tex.Apply ();
// Encode texture into PNG
Byte[] bytes = tex.EncodeToPNG();
Destroy (tex);
File.WriteAllBytes(Application.dataPath + "/../SavedScreen.png", bytes);
}
复制代码
作者:
oelongeo
时间:
2014-11-30 11:27
长知识了 ! 谢谢指导 ! 脚本真实用
作者:
HIDEOKOJIMA
时间:
2014-11-30 19:00
Thank you guide! very useful code
欢迎光临 纳金网 (http://old.narkii.com/club/)
Powered by Discuz! X2.5