比如用unity3D导出的应用跑4K分辨率,想截取左下4分之一屏的 保存一张 texture,分辨率也为4K,有没有大神知道??
使用ScreenCapture.CaptureScreenshot() 虽然能整体放大数倍,但是无法设置具体的截图范围和大小。
类似以下方法可截取自己设定的位置和大小,但是大小无法大于当前应用运行 的分辨率。
IEnumerator SavePhoto(Rect rect,string name)
{
yield return new WaitForEndOfFrame();
Texture2D t = new Texture2D(rect.width, rect.height);
t.ReadPixels(new Rect(0, 0, rect.width, rect.height), 0, 0, false);
//距X左的距离 距Y屏上的距离
// t.ReadPixels(rect, 0, 0, false);
t.Apply();
byte[] byts = t.EncodeToJPG(100);
File.WriteAllBytes(path_Save + name + ".jpg", byts);
}