mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-05 05:09:07 +08:00
21 lines
343 B
Go
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
|
|
}
|