이 메서드는 스크린 샷을 찍은 다음 이미지를 호출하는 메서드로 반환해야합니다.어떻게 비트 맵 형식을 반환합니까?
Bitmap bitmap = MyClass.TakeScreenshot(0, 0, 200, 200);
bitmap.Save(@"C:\test.jpg", ImageFormat.Jpeg);
그럼 난 저장-방법에서 오류가 발생합니다 :
public static Bitmap TakeScreenshot(int x, int y, int height, int width)
{
Rectangle bounds = new Rectangle(0, 0, height, width);
Bitmap bitmap;
using (bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(x, y), Point.Empty, bounds.Size);
}
}
return bitmap;
}
문제는 내가 사진을 저장하려고하면 때문이다.
ArgumentException 처리되지 않았습니다. 매개 변수가 유효하지 않습니다.
이 같은 방법 내부에 저장하려고하면 그것은 잘 작동 : 내가 여기서 뭘
public static Bitmap TakeScreenshot(int x, int y, int height, int width)
{
Rectangle bounds = new Rectangle(0, 0, height, width);
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(x, y), Point.Empty, bounds.Size);
}
bitmap.Save(@"c:\begin.tiff", ImageFormat.Tiff);
}
}
를 놓친 거지?
두 번째 방법으로 JPEG로 저장하려고 했습니까? 지금 당장 통과하고 실패하는 코드는 두 가지 형식으로 저장하려고합니다. –
혼란을 피하기 위해 나는 이것을 알고 있었을 것입니다. 그러나 장래에 같은 형식으로 저장됩니다. –