mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
add byte to image function
This commit is contained in:
parent
fec092bfd7
commit
0d7798c6c3
@ -49,6 +49,7 @@ package robotgo
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
@ -1126,6 +1127,12 @@ func DecodeImg(path string) (image.Image, string, error) {
|
|||||||
return imgo.DecodeFile(path)
|
return imgo.DecodeFile(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ByteToImg convert []byte to image.Image
|
||||||
|
func ByteToImg(b []byte) (image.Image, error) {
|
||||||
|
img, _, err := image.Decode(bytes.NewReader(b))
|
||||||
|
return img, err
|
||||||
|
}
|
||||||
|
|
||||||
// ToImage convert C.MMBitmapRef to standard image.Image
|
// ToImage convert C.MMBitmapRef to standard image.Image
|
||||||
func ToImage(bit C.MMBitmapRef) image.Image {
|
func ToImage(bit C.MMBitmapRef) image.Image {
|
||||||
bmp1 := ToBitmap(bit)
|
bmp1 := ToBitmap(bit)
|
||||||
|
Loading…
Reference in New Issue
Block a user