- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个 WinForms 应用程序,它按设定的时间间隔截取屏幕截图。我认为我的代码是正确的,但是当我尝试运行它时,我收到错误消息“System.Runtime.InteropServices.ExternalException 未处理,GDI+ 中发生一般错误。”
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
Thread th;
private static Bitmap bmpScreenshot;
private static Graphics gfxScreenshot;
void TakeScreenShot()
{
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
bmpScreenshot.Save(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\ScreenCaptures", ImageFormat.Png);
th.Abort();
}
void StartThread(object sender, EventArgs e)
{
th = new Thread(new ThreadStart(TakeScreenShot));
th.Start();
}
private void Form1_Load(object sender, EventArgs e)
{
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\ScreenCaptures");
t.Interval = 500;
t.Tick += new EventHandler(StartThread);
t.Start();
}
给我带来麻烦的是:
bmpScreenshot.Save(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\ScreenCaptures", ImageFormat.Png);
关于出了什么问题有什么想法吗?提前致谢。
最佳答案
您需要使用实际文件名保存,如下所示:
bmpScreenshot.Save(Environment.GetFolderPath
(Environment.SpecialFolder.DesktopDirectory)
+ @"\ScreenCaptures\newfile.png", ImageFormat.Png);
您的代码传递的路径不包含文件名。此外,请检查以确保 Environment.GetFolderPath(...) 返回的路径末尾没有“\”,否则您的路径中会出现“\\”。
关于C# - 基于定时器截屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2549624/
我需要截屏并保存截屏。我需要在不使用与 PC 的任何连接或不取消手机根目录的情况下执行此操作。每当触发事件时,我都需要这样做。例如,当游戏中显示广告时......或者当游戏结束并显示蛇的分数等时。你能
我正在尝试捕捉(屏幕截图) View 。为此,我使用下面显示的一段代码将其作为 PNG 图像保存到我的文档目录中。 UIGraphicsBeginImageContextWithOptions(hig
本文实例总结了常见的java编程实现屏幕截图方法。分享给大家供大家参考,具体如下: 方法一: ?
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
我正在构建一个跨平台桌面应用程序。我正在使用 electronjs 框架开发我的桌面应用程序。我想在我的应用程序启动时添加每 5 分钟截取一次屏幕截图的功能! 帮助将不胜感激我的 main.js //
我从另一个包导入这个类并尝试调用这个方法,但它不起作用。 当我在同一个类中创建此方法并调用它时,它正在工作。 private void getScreenshot() throws IOExcept
我正在尝试截取增强现实屏幕的屏幕截图并将其作为位图传递给另一个 Activity 。 这是我用来截取屏幕截图的代码: 截屏功能 public static void tmpScreenshot(Bit
我有一个绘图区,我在里面画了一些图形或图像,所以我有这个回调来截屏: void CanvasToolBox::actionCanvasCamera() { auto root = Gdk::W
我正在使用 AVCaptureMetadataOutput 以使用 iOS QRCode、条形码扫描功能。这很好用,我得到了通过 AVCaptureMetadataOutput 委托(delegate
我想截取我 View 中特定部分的屏幕截图(具体来说是 ImageView ),是否有机会.... 最佳答案 看来您需要执行 renderInContext。 // Size of the resul
这个问题在这里已经有了答案: Read binary stdout data like screencap data from adb shell? (19 个回答) 关闭5年前. 我正在尝试尽快获取
嘿,我正在使用 WEBRTC 进行屏幕共享。但是我被困在我需要用户整个屏幕的地方,但是浏览器为用户提供了更多选项,例如应用程序和浏览器选项卡,所以我想检查用户从浏览器产生的弹出窗口中选择的选项,如果它
我正在压力测试中测试应用程序。 这就是为什么我需要它在发生错误(错误窗口打开)或挂起或崩溃时重新启动。同时,我需要收集有关导致重启的问题的所有有用信息:制作转储文件,并从错误窗口复制错误文本(和/或获
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
嗨,这里有人可以帮助我使用 phantomJS 截取我的 div 吗?我如何截取我的 #dropzone 然后将其附加到同一页面? 请帮忙。 最佳答案 有两种方法可以部分呈现网页。 1) 只用 div
这是我写的用于保存网页截图的简单python代码。 from selenium import webdriver import time driver=webdriver.Firefox() driv
出于安全原因,我当前正在构建的应用程序要求应用程序必须阻止操作系统在应用程序被插入后台时截取该应用程序的屏幕截图。这样在应用之间切换时将无法看到最后一个 Activity 屏幕。 我打算将此功能放在应
我正在尝试从 Silverlight 5 应用程序中截取子类 XNA DrawingSurface 元素的屏幕截图。这个 sl 应用程序将在一个 aspx 页面内运行。 这是我迄今为止尝试过但没有成功
我正在使用 Xcode 构建 iPhone/iPad 应用程序。 现在我想截取这个应用程序的屏幕截图。 尺寸为 960x640。 那怎么办? 模拟器屏幕太小 最佳答案 您可以使用 cmd+S进入模拟器
我找到了一些代码示例,但我不知道哪些 JNA 版本可以使用哪些方法。我只找到了一些片段,其中缺少类,而且我无法导入它们。 我想知道我应该使用哪个 JNA 版本以及如何获取 BufferedImage
我是一名优秀的程序员,十分优秀!