我试过两种不同的方法来实现这一点,第一种是Android风格的方法,第二种是OpenGL风格的方法。从我的活动中,我创建了一个包含OpenGL(1.1)代码的视图。如何在Xamarin for Android中使用OpenTK作为位图获取OpenGL渲染?
第一种方法(机器人):
Bitmap b = gameView.GetDrawingCache (true); // this is always null
而第二个方法(OpenGL的):
public Bitmap GrabScreenshot()
{
int size = Width * Height * 4;
byte[] bytes = new byte[size];
GL.ReadPixels<byte>(0, 0, Width, Height, All.Rgba, All.UnsignedByte, bytes);
Bitmap bmp = BitmapFactory.DecodeByteArray (bytes, 0, size);
return bmp;
}
感谢您的答复。我在OpenTK网站上看到了这一点,我只是不确定如何将这些代码翻译成在Xamarin中可用的东西。 – Chris