mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Merge pull request #378 from go-vgo/bitmap-pr
Update README.md and add more image function
This commit is contained in:
commit
6542298646
18
README.md
18
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"
|
||||
|
18
README_zh.md
18
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"
|
||||
|
15
img.go
15
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
|
||||
|
Loading…
Reference in New Issue
Block a user