Tag: 截图

以编程方式截取部分隐藏窗口的屏幕截图

是否有可能获得一个不在顶部的窗口的屏幕截图,即它是否被另一个窗口部分隐藏,而不是将其置于顶部?

创建位图时C#内存不足

我正在创建一个应用程序(Windows窗体),允许用户根据他们选择的位置截取屏幕截图(拖动到选择区域)。 我想添加一个放大的“预览窗格”,以便用户可以更精确地选择他们想要的区域(更大的像素)。 在mousemove事件中,我有以下代码…… private void falseDesktop_MouseMove(object sender, MouseEventArgs e) { zoomBox.Image = showZoomBox(e.Location); zoomBox.Invalidate(); bmpCrop.Dispose(); } private Image showZoomBox(Point curLocation) { Point start = new Point(curLocation.X – 50, curLocation.Y – 50); Size size = new Size(100, 90); Rectangle rect = new Rectangle(start, size); Image selection = cropImage(falseDesktop.Image, rect); return selection; } private static Bitmap bmpCrop; […]

在XNA中拍摄屏幕截图

如何在XNA中截取屏幕截图? 没有System.Drawing.Graphics.CopyFromScreen或Win32API可以吗? 如果不可能,有没有办法将System.Drawing.Bitmap绘制到游戏中? 我希望它会采用屏幕截图,然后以全屏模式加载游戏,然后打印屏幕截图。 谢谢。

WPF:获取屏幕截图的方法

希望修改以下内容以截取所有显示器的屏幕截图。 我试过调整它但我的图像是空白的。 将它写入test.png是为了测试。 byte[]将被发送到接收应用程序。 public byte[] Take() { int screenWidth = Convert.ToInt32(SystemParameters.VirtualScreenWidth); int screenHeight = Convert.ToInt32(SystemParameters.VirtualScreenHeight); int screenLeft = Convert.ToInt32(SystemParameters.VirtualScreenLeft); int screenTop = Convert.ToInt32(SystemParameters.VirtualScreenTop); RenderTargetBitmap renderTarget = new RenderTargetBitmap(screenWidth, screenHeight, 96, 96, PixelFormats.Pbgra32); VisualBrush sourceBrush = new VisualBrush(); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); using (drawingContext) { drawingContext.PushTransform(new ScaleTransform(1, 1)); drawingContext.DrawRectangle(sourceBrush, null, […]

截图方法生成黑色图像

在c#中未能使用control.drawtobitmap之后,我的第二个选择是获取桌面的屏幕截图并裁剪出所需的部分。 一旦我切换用户帐户,我的打嗝就出现了,虽然程序没有崩溃,一旦用户切换,程序只生成纯黑图像。 我用这个代码作为参考: WebBrowser.DrawToBitmap()或其他方法? 我认为逻辑上这是有道理的,因为这将有助于Windows节省资源。 在我的情况下,我有哪些选择/解决方案? 编辑1对代码进行了修改以进行测试: int c = 0; while (true) { try { c++; Rectangle formBounds = this.Bounds; Bitmap bmp = new Bitmap(formBounds.Width, formBounds.Height); using (Graphics g = Graphics.FromImage(bmp)) g.CopyFromScreen(formBounds.Location, Point.Empty, formBounds.Size); bmp.Save(“picture” + c.ToString() + “.jpg”); Thread.Sleep(5000); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } 这在用户帐户上完美运行,但是一旦我切换用户,它就会返回exception:句柄无效。 有任何想法吗? 编辑2: DrawToBitmap中的错误并不是随机的…如果我使用了您提供的代码: Bitmap bmp […]

C#:如何拍摄部分屏幕的截图

喜欢 TakeScreenshot(new Rectangle(0,0,100,100), “output.jpg”);