在我的项目中,我需要获取正在显示的屏幕的亮度。为此,我获取屏幕快照并将其设置为 Texture2D
要获取快照并将其转换,我使用以下命令:
public void GetScreen(ref Texture2D screenShot){
RenderTexture rt = new RenderTexture(Screen.Width, Screen.Height, 24);
camera.targetTexture = rt;
screenShot = new Texture2D(Screen.Width, Screen.Height, TextureFormat.RGB24, false);
camera.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, Sreen.Width, Screen.Height), 0, 0);
camera.targetTexture = null;
RenderTexture.active = null;
Destroy(rt);
}
但我仍然需要获得亮度。
任何建议都将被接受(关于亮度和/或关于转换)。
提前致谢。