Skip to content

Commit

Permalink
capture error (#663)
Browse files Browse the repository at this point in the history
* capture error

* aohanhongzhi

* Update go.mod

---------

Co-authored-by: Evans <[email protected]>
  • Loading branch information
aohanhongzhi and vcaesar authored Oct 7, 2024
1 parent 217d6cf commit 8db59aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions robotgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ package robotgo
import "C"

import (
"errors"
"image"
"runtime"
"time"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8db59aa

Please sign in to comment.