Merge pull request #560 from go-vgo/bitmap-pr

Update: update and add more examples
This commit is contained in:
Evans 2023-02-01 10:28:44 -08:00 committed by GitHub
commit e4848b4608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -7,16 +7,30 @@ import (
)
func main() {
//
// syscall.NewLazyDLL("user32.dll").NewProc("SetProcessDPIAware").Call()
width, height := robotgo.GetScaleSize()
fmt.Println("get scale screen size: ", width, height)
bitmap := robotgo.CaptureScreen(0, 0, width, height)
// robotgo.SaveBitmap(bitmap, "test.png")
defer robotgo.FreeBitmap(bitmap)
// bitmap.Save(bitmap, "test.png")
robotgo.Save(robotgo.ToImage(bitmap), "test.png")
robotgo.Scale = true
robotgo.Move(10, 10)
robotgo.MoveSmooth(100, 100)
fmt.Println(robotgo.Location())
num := robotgo.DisplaysNum()
for i := 0; i < num; i++ {
rect := robotgo.GetScreenRect(i)
fmt.Println("rect: ", rect)
}
}
func old() {
sx := robotgo.ScaleX() // Deprecated
s := robotgo.Scale1() // Deprecated, use the ScaleF() function
robotx, roboty := 35*s/100, 25*s/100
@ -28,7 +42,8 @@ func main() {
rx, ry, rw, rh := sx, sy, robotx, roboty
// bit1 := robotgo.CaptureScreen(10, 20, robotw, roboth)
bit1 := robotgo.CaptureScreen(rx, ry, rw, rh)
// robotgo.SaveBitmap(bit1, "test2.png")
defer robotgo.FreeBitmap(bit1)
// bitmap.Save(bit1, "test2.png")
robotgo.Save(robotgo.ToImage(bit1), "test2.png")
clo := robotgo.GetPixelColor(robotx, roboty)

View File

@ -20,7 +20,9 @@ import (
func bitmap() {
bit := robotgo.CaptureScreen()
defer robotgo.FreeBitmap(bit)
fmt.Println("abitMap...", bit)
gbit := robotgo.ToBitmap(bit)
fmt.Println("bitmap...", gbit.Width)