This commit is contained in:
aohanhongzhi 2024-10-06 18:49:40 -07:00 committed by GitHub
commit 4273e546ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/go-vgo/robotgo
module github.com/aohanhongzhi/robotgo
go 1.22

View File

@ -50,6 +50,7 @@ package robotgo
import "C"
import (
"errors"
"image"
"runtime"
"time"
@ -366,11 +367,14 @@ func CaptureGo(args ...int) Bitmap {
}
// CaptureImg capture the screen and return image.Image
func CaptureImg(args ...int) image.Image {
func CaptureImg(args ...int) (image.Image, error) {
bit := CaptureScreen(args...)
if bit == nil {
return nil, errors.New("capture error")
}
defer FreeBitmap(bit)
return ToImage(bit)
return ToImage(bit), nil
}
// FreeBitmap free and dealloc the C bitmap