mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-29 21:43:55 +00:00
capture error (#663)
* capture error * aohanhongzhi * Update go.mod --------- Co-authored-by: Evans <vzvway@gmail.com>
This commit is contained in:
parent
217d6cf1f1
commit
8db59aac2d
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user