From db6723eb00020f845a05e389c10bfdcca7762bbf Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 18 Oct 2021 10:52:35 -0400 Subject: [PATCH 1/2] Update README.md --- README.md | 18 +++++++++++++++++- README_zh.md | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index edc3e50..80c9e10 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,6 @@ import ( "fmt" "github.com/go-vgo/robotgo" - "github.com/vcaesar/gcv" ) func main() { @@ -251,6 +250,23 @@ func main() { robotgo.SaveBitmap(bitmap, "test.png") } +``` + +#### [OpenCV](https://github.com/vcaesar/gcv) + +```Go +package main + +import ( + "fmt" + + "github.com/go-vgo/robotgo" + "github.com/vcaesar/gcv" +) + +func main() { + opencv() +} func opencv() { name := "test.png" diff --git a/README_zh.md b/README_zh.md index 71eba4e..b971b07 100644 --- a/README_zh.md +++ b/README_zh.md @@ -224,7 +224,6 @@ import ( "fmt" "github.com/go-vgo/robotgo" - "github.com/vcaesar/gcv" ) func main() { @@ -249,6 +248,23 @@ func main() { robotgo.SaveBitmap(bitmap, "test.png") } +``` + +#### [OpenCV](https://github.com/vcaesar/gcv) + +```Go +package main + +import ( + "fmt" + + "github.com/go-vgo/robotgo" + "github.com/vcaesar/gcv" +) + +func main() { + opencv() +} func opencv() { name := "test.png" From 3b92bb6207ea6987f85be9971744c5af9445746d Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 18 Oct 2021 10:55:14 -0400 Subject: [PATCH 2/2] add more image function --- img.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/img.go b/img.go index 69d2d30..6409cf8 100644 --- a/img.go +++ b/img.go @@ -72,6 +72,21 @@ func ByteToImg(b []byte) (image.Image, error) { return imgo.ByteToImg(b) } +// ImgSize get the file image size +func ImgSize(path string) (int, int, error) { + return imgo.GetSize(path) +} + +// Width return the image.Image width +func Width(img image.Image) int { + return img.Bounds().Max.X +} + +// Height return the image.Image height +func Height(img image.Image) int { + return img.Bounds().Max.Y +} + // RGBAToBitmap convert the standard image.RGBA to Bitmap func RGBAToBitmap(r1 *image.RGBA) (bit Bitmap) { bit.Width = r1.Bounds().Size().X