5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-05 05:09:07 +08:00
wails/v3/pkg/application/image.go
2023-05-30 16:31:54 +08:00

21 lines
343 B
Go

package application
import (
"bytes"
"image"
"image/draw"
"image/png"
)
func pngToImage(data []byte) (*image.RGBA, error) {
img, err := png.Decode(bytes.NewReader(data))
if err != nil {
return nil, err
}
bounds := img.Bounds()
rgba := image.NewRGBA(bounds)
draw.Draw(rgba, bounds, img, bounds.Min, draw.Src)
return rgba, nil
}