I am writing a golang program using go-bindata
to embed the image resources, and use the Asset(string) ([]byte, error)
function to access resources. But my existing library codes go like this:
func NewIconFromFile(filePath string) (uintptr, error) {
absFilePath, err := filepath.Abs(filePath)
if err != nil {
return 0, err
}
hicon, _, _ := LoadImage.Call(
0,
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(absFilePath))),
IMAGE_ICON,
0,
0,
LR_DEFAULTSIZE|LR_LOADFROMFILE)
if hicon == 0 {
return 0, errors.New("load image failed: " + filePath)
}
return hicon, nil
}
How can I rewrite this functions to:
func NewIconFromRawBytes(imgBytes []byte) (uintptr, error)
so it can support for loading images from []byte
? Any helps? thanks.
Edit: There is a similar c++ version question, how can I port it to golang.