mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Update: update screen capture code and examples
This commit is contained in:
parent
8db59aac2d
commit
47cde13dab
@ -1,5 +1,5 @@
|
|||||||
# FROM golang:1.10.1
|
# 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
|
# FROM govgo/go:1.11.1
|
||||||
|
|
||||||
RUN apt update && apt install -y --no-install-recommends \
|
RUN apt update && apt install -y --no-install-recommends \
|
||||||
|
@ -366,11 +366,11 @@ func CaptureGo(args ...int) Bitmap {
|
|||||||
return ToBitmap(bit)
|
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) {
|
func CaptureImg(args ...int) (image.Image, error) {
|
||||||
bit := CaptureScreen(args...)
|
bit := CaptureScreen(args...)
|
||||||
if bit == nil {
|
if bit == nil {
|
||||||
return nil, errors.New("capture error")
|
return nil, errors.New("Capture image not found.")
|
||||||
}
|
}
|
||||||
defer FreeBitmap(bit)
|
defer FreeBitmap(bit)
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
package robotgo
|
package robotgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
"github.com/kbinani/screenshot"
|
"github.com/kbinani/screenshot"
|
||||||
@ -31,7 +30,7 @@ func GetDisplayRect(i int) Rect {
|
|||||||
Size{W: w, H: h}}
|
Size{W: w, H: h}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture capture the screenshot
|
// Capture capture the screenshot, use the CaptureImg default
|
||||||
func Capture(args ...int) (*image.RGBA, error) {
|
func Capture(args ...int) (*image.RGBA, error) {
|
||||||
displayId := 0
|
displayId := 0
|
||||||
if DisplayID != -1 {
|
if DisplayID != -1 {
|
||||||
@ -54,9 +53,9 @@ func Capture(args ...int) (*image.RGBA, error) {
|
|||||||
|
|
||||||
// SaveCapture capture screen and save the screenshot to image
|
// SaveCapture capture screen and save the screenshot to image
|
||||||
func SaveCapture(path string, args ...int) error {
|
func SaveCapture(path string, args ...int) error {
|
||||||
img := CaptureImg(args...)
|
img, err := CaptureImg(args...)
|
||||||
if img == nil {
|
if err != nil {
|
||||||
return errors.New("Capture image not found")
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return Save(img, path)
|
return Save(img, path)
|
||||||
|
Loading…
Reference in New Issue
Block a user