diff --git a/.circleci/images/primary/Dockerfile b/.circleci/images/primary/Dockerfile index ceaf93bd..98f4a97a 100644 --- a/.circleci/images/primary/Dockerfile +++ b/.circleci/images/primary/Dockerfile @@ -1,5 +1,5 @@ # FROM golang:1.10.1 -FROM golang:1.22.3-stretch AS build +FROM golang:1.23.2-stretch AS build # FROM govgo/go:1.11.1 RUN apt update && apt install -y --no-install-recommends \ diff --git a/robotgo.go b/robotgo.go index b7b68882..7fcca4ce 100644 --- a/robotgo.go +++ b/robotgo.go @@ -366,11 +366,11 @@ func CaptureGo(args ...int) Bitmap { return ToBitmap(bit) } -// CaptureImg capture the screen and return image.Image +// CaptureImg capture the screen and return image.Image, error func CaptureImg(args ...int) (image.Image, error) { bit := CaptureScreen(args...) if bit == nil { - return nil, errors.New("capture error") + return nil, errors.New("Capture image not found.") } defer FreeBitmap(bit) diff --git a/screen.go b/screen.go index 1e23bba7..5062b11c 100644 --- a/screen.go +++ b/screen.go @@ -11,7 +11,6 @@ package robotgo import ( - "errors" "image" "github.com/kbinani/screenshot" @@ -31,7 +30,7 @@ func GetDisplayRect(i int) Rect { Size{W: w, H: h}} } -// Capture capture the screenshot +// Capture capture the screenshot, use the CaptureImg default func Capture(args ...int) (*image.RGBA, error) { displayId := 0 if DisplayID != -1 { @@ -54,9 +53,9 @@ func Capture(args ...int) (*image.RGBA, error) { // SaveCapture capture screen and save the screenshot to image func SaveCapture(path string, args ...int) error { - img := CaptureImg(args...) - if img == nil { - return errors.New("Capture image not found") + img, err := CaptureImg(args...) + if err != nil { + return err } return Save(img, path)