mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +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 (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
@ -1126,6 +1127,12 @@ func DecodeImg(path string) (image.Image, string, error) {
|
||||
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
|
||||
func ToImage(bit C.MMBitmapRef) image.Image {
|
||||
bmp1 := ToBitmap(bit)
|
||||
|
Loading…
Reference in New Issue
Block a user