Compare commits

...

3 Commits

Author SHA1 Message Date
aohanhongzhi
ed6fabf715
Merge 932a918e44 into 0de26ecee4 2024-09-17 18:46:01 -07:00
eric
932a918e44 aohanhongzhi 2024-06-18 20:27:53 +08:00
eric
3f4b0f9872 capture error 2024-06-18 20:20:04 +08:00
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 go 1.22

View File

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