我试图制作一部温树胶片,在固定间隔中播放。 我认为,我的守则是正确的,但在我试图操作时,我收到了错误的信息“System.Runtime.Interop Servicess”。 外部外观没有处理,在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);
任何关于什么会错的想法? 提前感谢。