mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
add more image function support
This commit is contained in:
parent
4dcdfe7f42
commit
2768d0877a
@ -15,7 +15,7 @@
|
||||
<!-- [](https://github.com/go-vgo/robotgo/releases/latest) -->
|
||||
<!-- <a href="https://github.com/go-vgo/robotgo/releases"><img src="https://img.shields.io/badge/%20version%20-%206.0.0%20-blue.svg?style=flat-square" alt="Releases"></a> -->
|
||||
|
||||
>Golang Desktop Automation. Control the mouse, keyboard, bitmap and image, read the screen, process, Window Handle and global event listener.
|
||||
> Golang Desktop Automation. Control the mouse, keyboard, bitmap and image, read the screen, process, Window Handle and global event listener.
|
||||
|
||||
RobotGo supports Mac, Windows, and Linux(X11); and robotgo supports arm64 and x86-amd64.
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
[](https://github.com/go-vgo/robotgo/releases/latest)
|
||||
[](https://gitter.im/go-vgo/robotgo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
>Golang 跨平台自动化系统,控制键盘、鼠标、位图、图像、读取屏幕,进程、窗口句柄以及全局事件监听
|
||||
> Golang 跨平台自动化系统,控制键盘、鼠标、位图、图像、读取屏幕,进程、窗口句柄以及全局事件监听
|
||||
|
||||
RobotGo 支持 Mac, Windows, and Linux(X11).
|
||||
|
||||
|
@ -34,6 +34,7 @@ func toBitmap(bmp robotgo.CBitmap) {
|
||||
robotgo.SaveBitmap(cbit, "tocbitmap.png")
|
||||
}
|
||||
|
||||
// find color
|
||||
func findColor(bmp robotgo.CBitmap) {
|
||||
bitmap := robotgo.ToMMBitmapRef(bmp)
|
||||
|
||||
@ -105,7 +106,7 @@ func decode() {
|
||||
fmt.Println("decode test.png", img, name)
|
||||
|
||||
byt, _ := robotgo.OpenImg("test.png")
|
||||
imgo.Save("test2.png", byt)
|
||||
imgo.SaveByte("test2.png", byt)
|
||||
|
||||
w, h := robotgo.GetImgSize("test.png")
|
||||
fmt.Println("image width and hight ", w, h)
|
||||
|
4
go.mod
4
go.mod
@ -9,8 +9,8 @@ require (
|
||||
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934
|
||||
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770
|
||||
github.com/vcaesar/gops v0.21.2
|
||||
github.com/vcaesar/imgo v0.20.0
|
||||
github.com/vcaesar/tt v0.11.0
|
||||
github.com/vcaesar/imgo v0.30.0
|
||||
github.com/vcaesar/tt v0.20.0
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
|
||||
)
|
||||
|
7
go.sum
7
go.sum
@ -33,10 +33,11 @@ github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2bi
|
||||
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
|
||||
github.com/vcaesar/gops v0.21.2 h1:OwWoJR0zb+AK41TN2adhZUP9lAmaRMzkWwf7Ux5Mx00=
|
||||
github.com/vcaesar/gops v0.21.2/go.mod h1:BEJGigAc9GORbEegWX9rRon/qwibjDs8p50WYm2KlXw=
|
||||
github.com/vcaesar/imgo v0.20.0 h1:lX7a2vygTri0Z3VYpwoQA2LPvbphFyT5ON4NTqdC4wQ=
|
||||
github.com/vcaesar/imgo v0.20.0/go.mod h1:eJscuTEdc6sVn/hZruy8kWi61xqKHLtbAYyPeYcn+t4=
|
||||
github.com/vcaesar/tt v0.11.0 h1:obQecjgbnAxxC6OYGY6yDvhGRW2PR5wD8Ma2uJH3WGA=
|
||||
github.com/vcaesar/imgo v0.30.0 h1:ODQVX0EFJEh+WkKahCBtE0SqcDCIjl/kjiOplR0Ouh8=
|
||||
github.com/vcaesar/imgo v0.30.0/go.mod h1:8TGnt5hjaMgwDByvMFIzUDSh5uSea4n1tAbSvnhvA6U=
|
||||
github.com/vcaesar/tt v0.11.0/go.mod h1:GHPxQYhn+7OgKakRusH7KJ0M5MhywoeLb8Fcffs/Gtg=
|
||||
github.com/vcaesar/tt v0.20.0 h1:9t2Ycb9RNHcP0WgQgIaRKJBB+FrRdejuaL6uWIHuoBA=
|
||||
github.com/vcaesar/tt v0.20.0/go.mod h1:GHPxQYhn+7OgKakRusH7KJ0M5MhywoeLb8Fcffs/Gtg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||
|
20
img.go
20
img.go
@ -27,9 +27,19 @@ func OpenImg(path string) ([]byte, error) {
|
||||
return imgo.ImgToBytes(path)
|
||||
}
|
||||
|
||||
// Read read the file return image.Image
|
||||
func Read(path string) (image.Image, error) {
|
||||
return imgo.Read(path)
|
||||
}
|
||||
|
||||
// Save create a image file with the image.Image
|
||||
func Save(img image.Image, path string) error {
|
||||
return imgo.Save(path, img)
|
||||
}
|
||||
|
||||
// SaveImg save the image by []byte
|
||||
func SaveImg(b []byte, path string) error {
|
||||
return imgo.Save(path, b)
|
||||
return imgo.SaveByte(path, b)
|
||||
}
|
||||
|
||||
// SavePng save the image by image.Image
|
||||
@ -43,13 +53,13 @@ func SaveJpeg(img image.Image, path string) error {
|
||||
}
|
||||
|
||||
// ToByteImg convert image.Image to []byte
|
||||
func ToByteImg(img image.Image) []byte {
|
||||
return imgo.ToByteImg(img)
|
||||
func ToByteImg(img image.Image, fm ...string) []byte {
|
||||
return imgo.ToByteImg(img, fm...)
|
||||
}
|
||||
|
||||
// ToStringImg convert image.Image to string
|
||||
func ToStringImg(img image.Image) string {
|
||||
return string(ToByteImg(img))
|
||||
func ToStringImg(img image.Image, fm ...string) string {
|
||||
return string(ToByteImg(img, fm...))
|
||||
}
|
||||
|
||||
// StrToImg convert base64 string to image.Image
|
||||
|
Loading…
Reference in New Issue
Block a user