diff --git a/robotgo.go b/robotgo.go index 1648574..661c4a4 100644 --- a/robotgo.go +++ b/robotgo.go @@ -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)