Skip to content

Commit 8db59aa

Browse files
capture error (#663)
* capture error * aohanhongzhi * Update go.mod --------- Co-authored-by: Evans <[email protected]>
1 parent 217d6cf commit 8db59aa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

robotgo.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ package robotgo
5050
import "C"
5151

5252
import (
53+
"errors"
5354
"image"
5455
"runtime"
5556
"time"
@@ -366,11 +367,14 @@ func CaptureGo(args ...int) Bitmap {
366367
}
367368

368369
// CaptureImg capture the screen and return image.Image
369-
func CaptureImg(args ...int) image.Image {
370+
func CaptureImg(args ...int) (image.Image, error) {
370371
bit := CaptureScreen(args...)
372+
if bit == nil {
373+
return nil, errors.New("capture error")
374+
}
371375
defer FreeBitmap(bit)
372376

373-
return ToImage(bit)
377+
return ToImage(bit), nil
374378
}
375379

376380
// FreeBitmap free and dealloc the C bitmap

0 commit comments

Comments
 (0)