mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
add more bitmap examples code
This commit is contained in:
parent
9468b8fdde
commit
cd0b69b3a1
4
.gitignore
vendored
4
.gitignore
vendored
@ -90,3 +90,7 @@ examples/bitmap/test_IMG.png
|
||||
examples/bitmap/imgToBitmap/test_01.png
|
||||
examples/bitmap/imgToBitmap/test_002.jpeg
|
||||
examples/bitmap/imgToBitmap/test_003.jpeg
|
||||
examples/bitmap/imgToBitmap/test_1.png
|
||||
examples/bitmap/imgToBitmap/test_2.jpeg
|
||||
examples/bitmap/imgToBitmap/test.png
|
||||
robot_img.png
|
||||
|
@ -1,14 +1,22 @@
|
||||
//go:build go1.16
|
||||
// +build go1.16
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-vgo/robotgo"
|
||||
"github.com/vcaesar/imgo"
|
||||
)
|
||||
|
||||
//go:embed test_01.png
|
||||
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)
|
||||
@ -20,4 +28,25 @@ func main() {
|
||||
|
||||
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_2.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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user