【发布时间】:2013-09-12 09:10:43
【问题描述】:
我刚刚开始编写这个小 C# 程序,目的无关紧要。现在它尝试制作整个屏幕的屏幕截图,它成功了......有点......
问题是我正在运行 200% 缩放的 Windows(不,我的视力并不差),当我运行此代码时,我只保存了 1/4 的屏幕(左上部分),而不是整体如预期。我非常确定这与 200% 缩放有关,我想问是否有人可以提出解决方法,以便它实际上捕获我的整个屏幕。代码如下:
string savePath = @"C:\Users\eltaro\Desktop\ScreenShot "+DateTime.Now.ToString("yyyy-MM-dd")+" at "+DateTime.Now.ToString("HH.mm")+".bmp";
bmpImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
gfxScreenshot = Graphics.FromImage(bmpImage);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0,
Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
bmpImage.Save(savePath, System.Drawing.Imaging.ImageFormat.Bmp);
【问题讨论】:
-
您应该验证
CopyFromScreen是否仍然泄漏句柄。如果您继续捕获屏幕截图,并且确实如此,您最终会用完句柄。
标签: c# windows zooming screenshot imaging