-
Notifications
You must be signed in to change notification settings - Fork 859
/
main.go
52 lines (38 loc) · 1.06 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//go:build go1.16
// +build go1.16
package main
import (
_ "embed"
"fmt"
"github.com/go-vgo/robotgo"
"github.com/vcaesar/imgo"
)
//go:embed test_007.jpeg
var testPng []byte
func main() {
bit1 := robotgo.CaptureScreen(300, 300, 100, 100)
defer robotgo.FreeBitmap(bit1)
robotgo.SaveBitmap(bit1, "test_003.jpeg")
m1 := robotgo.ToImage(bit1)
fmt.Println("m1: ", m1.Bounds())
imgo.SaveToPNG("test_01.png", m1)
r1 := robotgo.ToRGBA(bit1)
fmt.Println("r1: ", r1.Pix)
bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(m1))
robotgo.SaveBitmap(bit2, "test_002.jpeg")
test()
}
func test() {
bitmap := robotgo.CaptureScreen(10, 10, 10, 10)
defer robotgo.FreeBitmap(bitmap)
img := robotgo.ToImage(bitmap)
robotgo.SavePng(img, "test_1.png")
img1, _ := robotgo.ByteToImg(testPng)
robotgo.SaveJpeg(img1, "test_7.jpeg")
bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img))
fx, fy := robotgo.FindBitmap(bit2)
fmt.Println("FindBitmap------ ", fx, fy)
arr := robotgo.FindEveryBitmap(bit2)
fmt.Println("Find every bitmap: ", arr)
robotgo.SaveBitmap(bitmap, "test.png")
}