update bitmap examples

This commit is contained in:
vcaesar 2018-05-08 23:26:07 +08:00
parent 5e6a6187de
commit e31e3139d1
2 changed files with 21 additions and 12 deletions

View File

@ -35,10 +35,7 @@ func main() {
gbit := robotgo.ToBitmap(bitmap) gbit := robotgo.ToBitmap(bitmap)
fmt.Println("go bitmap", gbit, gbit.Width) fmt.Println("go bitmap", gbit, gbit.Width)
// searches for needle in bitmap // find the color in bitmap
fx, fy := robotgo.FindBit(bitmap)
fmt.Println("FindBitmap------", fx, fy)
color := robotgo.GetColor(bitmap, 1, 2) color := robotgo.GetColor(bitmap, 1, 2)
fmt.Println("color...", color) fmt.Println("color...", color)
cx, cy := robotgo.FindColor(bitmap, robotgo.CHex(color), 1.0) cx, cy := robotgo.FindColor(bitmap, robotgo.CHex(color), 1.0)
@ -58,9 +55,14 @@ func main() {
bit := robotgo.CaptureScreen(1, 2, 40, 40) bit := robotgo.CaptureScreen(1, 2, 40, 40)
fmt.Println("CaptureScreen...", bit) fmt.Println("CaptureScreen...", bit)
fx, fy = robotgo.FindBitmap(bit)
// searches for needle in bitmap
fx, fy := robotgo.FindBitmap(bit, bitmap)
fmt.Println("FindBitmap------", fx, fy) fmt.Println("FindBitmap------", fx, fy)
fx, fy = robotgo.FindBitmap(bit, bitmap) // fx, fy := robotgo.FindBit(bitmap)
// fmt.Println("FindBitmap------", fx, fy)
fx, fy = robotgo.FindBitmap(bit)
fmt.Println("FindBitmap------", fx, fy) fmt.Println("FindBitmap------", fx, fy)
abool := robotgo.PointInBounds(bitmap, 1, 2) abool := robotgo.PointInBounds(bitmap, 1, 2)
@ -107,4 +109,7 @@ func main() {
fx, fy = robotgo.FindPic("test.tif") fx, fy = robotgo.FindPic("test.tif")
fmt.Println("FindPic------", fx, fy) fmt.Println("FindPic------", fx, fy)
// free the bitmap
robotgo.FreeBitmap(abitMap)
} }

View File

@ -178,10 +178,7 @@ func bitmap() {
gbit := robotgo.ToBitmap(bitmap) gbit := robotgo.ToBitmap(bitmap)
fmt.Println("go bitmap", gbit, gbit.Width) fmt.Println("go bitmap", gbit, gbit.Width)
// searches for needle in bitmap // find the color in bitmap
fx, fy := robotgo.FindBit(bitmap)
fmt.Println("FindBitmap------", fx, fy)
color := robotgo.GetColor(bitmap, 1, 2) color := robotgo.GetColor(bitmap, 1, 2)
fmt.Println("color...", color) fmt.Println("color...", color)
cx, cy := robotgo.FindColor(bitmap, robotgo.CHex(color), 1.0) cx, cy := robotgo.FindColor(bitmap, robotgo.CHex(color), 1.0)
@ -201,9 +198,13 @@ func bitmap() {
bit := robotgo.CaptureScreen(1, 2, 40, 40) bit := robotgo.CaptureScreen(1, 2, 40, 40)
fmt.Println("CaptureScreen...", bit) fmt.Println("CaptureScreen...", bit)
fx, fy = robotgo.FindBitmap(bit)
// searches for needle in bitmap
fx, fy := robotgo.FindBitmap(bit, bitmap)
fmt.Println("FindBitmap------", fx, fy) fmt.Println("FindBitmap------", fx, fy)
fx, fy = robotgo.FindBitmap(bit, bitmap) // fx, fy := robotgo.FindBit(bitmap)
// fmt.Println("FindBitmap------", fx, fy)
fx, fy = robotgo.FindBitmap(bit)
fmt.Println("FindBitmap------", fx, fy) fmt.Println("FindBitmap------", fx, fy)
// bitmap := robotgo.CaptureScreen(10, 20, 30, 40) // bitmap := robotgo.CaptureScreen(10, 20, 30, 40)
@ -251,6 +252,9 @@ func bitmap() {
fx, fy = robotgo.FindPic("test.tif") fx, fy = robotgo.FindPic("test.tif")
fmt.Println("FindPic------", fx, fy) fmt.Println("FindPic------", fx, fy)
// free the bitmap
robotgo.FreeBitmap(abitMap)
} }
func event() { func event() {