为了给网络视频游戏编写AI程序,我想得到游戏的截图。没问题,我可以用GetWindowRect。
但是,这种方法实际上保存了一个屏幕截图,而不需要GPU应用的滤镜。我的意思是,我想要得到网页的真实颜色,而不是我在GPU处理后看到的那个。
表单识别实际上是基于颜色的,如果屏幕截图上没有人得到相同的颜色,我就不能发布这个AI。
有没有办法做到这一点?
--
PinkPR
发布于 2014-03-18 23:42:51
您需要以与在屏幕上呈现相同的方式呈现,但要呈现到位图的设备上下文中。提供关于主题的基本概念的示例代码:
..
..
//Application of matrices and usual program flow
//
..
//Get graphics from the bitmap previously created
Graphics gc = Graphics.FromImage(bmp)
//Get device context
IntPtr hDc = gc.GetHdc();
int iPixelFormat = Gdi.ChoosePixelFormat(hDc, ref pfd);
Gdi.SetPixelFormat(hDc, iPixelFormat, ref pfd);
IntPtr hRc = Wgl.wglCreateContext(hDc);
//Make it current
if (!Wgl.wglMakeCurrent(hDc, hRc))
{
throw new Exception("....");
}
//Render to hDc
https://stackoverflow.com/questions/22484107
复制相似问题