-
Notifications
You must be signed in to change notification settings - Fork 3
/
bitmap_test.go
42 lines (34 loc) · 875 Bytes
/
bitmap_test.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
package bitmap
import (
"fmt"
"testing"
"github.com/go-vgo/robotgo"
"github.com/vcaesar/tt"
)
func TestBitmap(t *testing.T) {
bit := robotgo.CaptureScreen()
defer robotgo.FreeBitmap(bit)
tt.NotNil(t, bit)
e := Save(bit, "robot_test.png")
tt.Nil(t, e)
bit0 := robotgo.CaptureScreen(10, 10, 20, 20)
defer robotgo.FreeBitmap(bit0)
x, y := Find(bit0)
fmt.Println("Find bitmap: ", x, y)
arr := FindAll(bit0, bit, 0.1)
fmt.Println("Find all bitmap:", arr)
fmt.Println("find len: ", len(arr))
// tt.Equal(t, 1, len(arr))
c1 := robotgo.CHex(0xAADCDC)
x, y = FindColor(c1)
fmt.Println("Find color: ", x, y)
arr = FindAllColor(c1)
fmt.Println("Find all color: ", arr)
img := robotgo.ToImage(bit)
err := robotgo.SavePng(img, "robot_img.png")
tt.Nil(t, err)
bit1 := Open("robot_test.png")
b := tt.TypeOf(bit, bit1)
tt.True(t, b)
tt.NotNil(t, bit1)
}