From 21dcd4de2b284b246f4b6416ec1a01c01d6a8c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=8B=BC=E7=8B=97?= Date: Fri, 11 Oct 2024 14:21:15 +0800 Subject: [PATCH] fix BitBlt error at same params (on x/y axis) --- .gitignore | 3 +++ windows.go | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1caac49 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# IDE tool cache +.idea/* +.vscode/* diff --git a/windows.go b/windows.go index 36e604f..02ed988 100644 --- a/windows.go +++ b/windows.go @@ -68,6 +68,9 @@ func Capture(x, y, width, height int) (*image.RGBA, error) { } defer win.SelectObject(memory_device, old) + if x == width || y == height { + return nil, errors.New("size failed (width or height are consistent)") + } if !win.BitBlt(memory_device, 0, 0, int32(width), int32(height), hdc, int32(x), int32(y), win.SRCCOPY) { return nil, errors.New("BitBlt failed") }