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

Update README.md and add more image function
This commit is contained in:
Evans 2021-10-18 10:57:01 -04:00 committed by GitHub
commit 6542298646
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 2 deletions

View File

@ -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"

View File

@ -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"

15
img.go
View File

@ -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