mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
add free bitmap array support and Update README.md
This commit is contained in:
parent
1498a7d32e
commit
336b7cea9f
17
README.md
17
README.md
@ -186,6 +186,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo"
|
"github.com/go-vgo/robotgo"
|
||||||
|
"github.com/vcaesar/imgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -197,6 +198,13 @@ func main() {
|
|||||||
|
|
||||||
sx, sy := robotgo.GetScreenSize()
|
sx, sy := robotgo.GetScreenSize()
|
||||||
fmt.Println("get screen size: ", sx, sy)
|
fmt.Println("get screen size: ", sx, sy)
|
||||||
|
|
||||||
|
bit := robotgo.CaptureScreen(10, 10, 30, 30)
|
||||||
|
defer robotgo.FreeBitmap(bit)
|
||||||
|
robotgo.SaveBimap(bit, "test_1.png")
|
||||||
|
|
||||||
|
img := robotgo.ToImage(bit)
|
||||||
|
imgo.Save("test.png", img)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -248,6 +256,15 @@ func opencv() {
|
|||||||
defer robotgo.FindBitmap(bit)
|
defer robotgo.FindBitmap(bit)
|
||||||
fmt.Print("find bitmap: ")
|
fmt.Print("find bitmap: ")
|
||||||
fmt.Println(robotgo.FindBitmap(bit))
|
fmt.Println(robotgo.FindBitmap(bit))
|
||||||
|
|
||||||
|
bit0 := robotgo.CaptureScreen()
|
||||||
|
img := robotgo.ToImage(bit0)
|
||||||
|
bit1 := robotgo.CaptureScreen(10, 10, 30, 30)
|
||||||
|
img1 := robotgo.ToImage(bit1)
|
||||||
|
defer robotgo.FreeBitmapArr(bit0, bit1)
|
||||||
|
|
||||||
|
fmt.Print("gcv find image: ")
|
||||||
|
fmt.Println(gcv.FindImg(img1, img))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
17
README_zh.md
17
README_zh.md
@ -184,6 +184,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo"
|
"github.com/go-vgo/robotgo"
|
||||||
|
"github.com/vcaesar/imgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -195,6 +196,13 @@ func main() {
|
|||||||
|
|
||||||
sx, sy := robotgo.GetScreenSize()
|
sx, sy := robotgo.GetScreenSize()
|
||||||
fmt.Println("get screen size: ", sx, sy)
|
fmt.Println("get screen size: ", sx, sy)
|
||||||
|
|
||||||
|
bit := robotgo.CaptureScreen(10, 10, 30, 30)
|
||||||
|
defer robotgo.FreeBitmap(bit)
|
||||||
|
robotgo.SaveBimap(bit, "test_1.png")
|
||||||
|
|
||||||
|
img := robotgo.ToImage(bit)
|
||||||
|
imgo.Save("test.png", img)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -246,6 +254,15 @@ func opencv() {
|
|||||||
defer robotgo.FindBitmap(bit)
|
defer robotgo.FindBitmap(bit)
|
||||||
fmt.Print("find bitmap: ")
|
fmt.Print("find bitmap: ")
|
||||||
fmt.Println(robotgo.FindBitmap(bit))
|
fmt.Println(robotgo.FindBitmap(bit))
|
||||||
|
|
||||||
|
bit0 := robotgo.CaptureScreen()
|
||||||
|
img := robotgo.ToImage(bit0)
|
||||||
|
bit1 := robotgo.CaptureScreen(10, 10, 30, 30)
|
||||||
|
img1 := robotgo.ToImage(bit1)
|
||||||
|
defer robotgo.FreeBitmapArr(bit0, bit1)
|
||||||
|
|
||||||
|
fmt.Print("gcv find image: ")
|
||||||
|
fmt.Println(gcv.FindImg(img1, img))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1215,12 +1215,19 @@ func Convert(opath, spath string, args ...int) {
|
|||||||
SaveBitmap(bitmap, spath, mtype)
|
SaveBitmap(bitmap, spath, mtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FreeBitmap free and dealloc bitmap
|
// FreeBitmap free and dealloc the C bitmap
|
||||||
func FreeBitmap(bitmap C.MMBitmapRef) {
|
func FreeBitmap(bitmap C.MMBitmapRef) {
|
||||||
// C.destroyMMBitmap(bitmap)
|
// C.destroyMMBitmap(bitmap)
|
||||||
C.bitmap_dealloc(bitmap)
|
C.bitmap_dealloc(bitmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FreeBitmapArr free and dealloc the C bitmap array
|
||||||
|
func FreeBitmapArr(bit ...C.MMBitmapRef) {
|
||||||
|
for i := 0; i < len(bit); i++ {
|
||||||
|
FreeBitmap(bit[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ReadBitmap returns false and sets error if |bitmap| is NULL
|
// ReadBitmap returns false and sets error if |bitmap| is NULL
|
||||||
func ReadBitmap(bitmap C.MMBitmapRef) bool {
|
func ReadBitmap(bitmap C.MMBitmapRef) bool {
|
||||||
abool := C.bitmap_ready(bitmap)
|
abool := C.bitmap_ready(bitmap)
|
||||||
|
Loading…
Reference in New Issue
Block a user