화면 캡처를하는 응용 프로그램을 작성하고 있지만 임의로 GDI + 일반 오류가 발생합니다. 불행히도 일반적인 오류는 디버깅에 도움이되지 않습니다.GDI +의 일반 오류가 화면 캡처에서 발생합니다.
이static void CaptureScreen()
{
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen
bmpScreenshot.Save(savePath + "img" + times.ToString()+ ".png", ImageFormat.Png);
}
가끔 나에게 일반 오류를 줄 것이다, 그래서 나는
static void CaptureScreen()
{
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen
bmpScreenshot.Save(savePath + "img" + times.ToString()+ ".png", ImageFormat.Png);
bmpScreenshot.Dispose();
gfxScreenshot.Dispose();
}
을 "어쩌면 나는 비트 맵과 변수 그래픽을 처리해야한다"다음 삭제를 생각 파일을 말했다 : 화면 캡처에 대한 나의 코드입니다 :
for (int i = 1; i == times; i++)
{
File.Delete(savePath + @"\img" + i.ToString() + ".png");
}
times = 0;
하지만 두 번 실행하면 동일한 파일에 쓰는 경우 파일이 사용 중이라고 표시됩니다. 어떤 아이디어?
는 "일반 GDI + 오류"에 대한 SO 검색 했습니까? 당신은 놀랄 것입니다 ... –
@ThorstenDittmar StackOverflow를 검색했지만 유사한 메소드 호출이있는 것을 찾을 수 없습니다. 어쩌면 나는 열심히 수색하지 않았을 것이다, 그렇다면 사과한다. – Thegluestickman