From 98daa9a2af888716fa0abcce426afab33602a793 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sat, 17 Mar 2018 16:59:25 +0800 Subject: [PATCH 1/2] add more image examples --- .gitignore | 1 + examples/bitmap/main.go | 11 +++++++++++ examples/main.go | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/.gitignore b/.gitignore index ee2e52a..f83994c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ examples/screen/screen examples/screen/saveCapture.png examples/bitmap/test.png +examples/bitmap/test2.png examples/bitmap/test.tif examples/bitmap/test31.tif test/test.png diff --git a/examples/bitmap/main.go b/examples/bitmap/main.go index 10e1fb5..6656671 100644 --- a/examples/bitmap/main.go +++ b/examples/bitmap/main.go @@ -12,8 +12,10 @@ package main import ( "fmt" + "log" "github.com/go-vgo/robotgo" + "github.com/vcaesar/imgo" // "go-vgo/robotgo" ) @@ -79,6 +81,15 @@ func main() { robotgo.SaveBitmap(bitmap, "test.png") robotgo.SaveBitmap(bitmap, "test31.tif", 1) + img, name, err := robotgo.DecodeImg("test.png") + if err != nil { + log.Println("decode image ", err) + } + fmt.Println("decode test.png", img, name) + + byt := robotgo.OpenImg("test.png") + imgo.Save("test2.png", byt) + // convert image robotgo.Convert("test.png", "test.tif") diff --git a/examples/main.go b/examples/main.go index 6211041..380300a 100644 --- a/examples/main.go +++ b/examples/main.go @@ -12,8 +12,10 @@ package main import ( "fmt" + "log" "github.com/go-vgo/robotgo" + "github.com/vcaesar/imgo" // "go-vgo/robotgo" ) @@ -219,6 +221,15 @@ func bitmap() { robotgo.SaveBitmap(bitmap, "test.png") robotgo.SaveBitmap(bitmap, "test31.tif", 1) + img, name, err := robotgo.DecodeImg("test.png") + if err != nil { + log.Println("decode image ", err) + } + fmt.Println("decode test.png", img, name) + + byt := robotgo.OpenImg("test.png") + imgo.Save("test2.png", byt) + // convert image robotgo.Convert("test.png", "test.tif") From 51999a0fa98b4404b47fd9d395ba27108a0b55b8 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sun, 18 Mar 2018 19:27:45 +0800 Subject: [PATCH 2/2] add more examples --- examples/bitmap/main.go | 5 +++++ examples/key/main.go | 6 +++++- examples/main.go | 11 ++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/bitmap/main.go b/examples/bitmap/main.go index 6656671..465f50a 100644 --- a/examples/bitmap/main.go +++ b/examples/bitmap/main.go @@ -90,6 +90,11 @@ func main() { byt := robotgo.OpenImg("test.png") imgo.Save("test2.png", byt) + w, h := robotgo.GetImgSize("test.png") + fmt.Println("image width and hight ", w, h) + w, h = imgo.GetSize("test.png") + fmt.Println("image width and hight ", w, h) + // convert image robotgo.Convert("test.png", "test.tif") diff --git a/examples/key/main.go b/examples/key/main.go index a294603..ba75ff0 100644 --- a/examples/key/main.go +++ b/examples/key/main.go @@ -26,11 +26,15 @@ func main() { robotgo.TypeString("Hello World") robotgo.TypeString("留给真爱你的人") + robotgo.MicroSleep(1) + robotgo.TypeStr("所以, 你好, 再见") + robotgo.Sleep(1) + ustr := uint32(robotgo.CharCodeAt("所以, 你好, 再见", 0)) robotgo.UnicodeType(ustr) - robotgo.PasteStr("粘贴字符串, paste") + robotgo.PasteStr(" 粘贴字符串, paste") // press "enter" robotgo.KeyTap("enter") diff --git a/examples/main.go b/examples/main.go index 380300a..2e908df 100644 --- a/examples/main.go +++ b/examples/main.go @@ -28,11 +28,15 @@ func key() { robotgo.TypeString("Hello World") robotgo.TypeString("留给真爱你的人") + robotgo.MicroSleep(1) + robotgo.TypeStr("所以, 你好, 再见") + robotgo.Sleep(1) + ustr := uint32(robotgo.CharCodeAt("所以, 你好, 再见", 0)) robotgo.UnicodeType(ustr) - robotgo.PasteStr("粘贴字符串, paste") + robotgo.PasteStr(" 粘贴字符串, paste") // press "enter" robotgo.KeyTap("enter") @@ -230,6 +234,11 @@ func bitmap() { byt := robotgo.OpenImg("test.png") imgo.Save("test2.png", byt) + w, h := robotgo.GetImgSize("test.png") + fmt.Println("image width and hight ", w, h) + w, h = imgo.GetSize("test.png") + fmt.Println("image width and hight ", w, h) + // convert image robotgo.Convert("test.png", "test.tif")