新手求助一下,关于屏幕拷贝的。
VS2008 C# winform, 正在做一个游戏截图的小程序。
启动游戏后,先全局 hook 一下某个按键,然后触发截图,图是截下来了,但发现问题,就是截图里有些图片只有背景图,一些物体的贴图根本没有截下来;但奇怪的是,有些截下来的图片却正常。。。百思不得其解,求教高人。
下面是我的很简单的截图部分代码,用的是 graphics.CopyFromScreen 方法。
public Bitmap PrintScreen(Size size, Point srcLoc)
{
Bitmap bitmap = new Bitmap(size.Width, size.Height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(new Point(srcLoc.X, srcLoc.Y), new Point(0, 0), new Size(size.Width, size.Height));
IntPtr dc1 = g.GetHdc();
g.ReleaseHdc(dc1);
g.Dispose();
return bitmap;
}
其中size.width height 分别为:Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, srcLoc.x y 值为0,0。