2018-12-02 15:02:19 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"image"
|
|
|
|
"image/draw"
|
|
|
|
|
|
|
|
_ "github.com/mat/besticon/ico"
|
|
|
|
)
|
|
|
|
|
|
|
|
func icoData(data []byte) (out []byte, width int, height int, err error) {
|
|
|
|
var ico image.Image
|
|
|
|
|
|
|
|
ico, _, err = image.Decode(bytes.NewReader(data))
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure that image is in RGBA format
|
|
|
|
rgba := image.NewRGBA(ico.Bounds())
|
2019-09-10 14:45:34 +02:00
|
|
|
draw.Draw(rgba, ico.Bounds(), ico, image.Point{}, draw.Src)
|
2018-12-02 15:02:19 +02:00
|
|
|
|
|
|
|
width = rgba.Bounds().Dx()
|
|
|
|
height = rgba.Bounds().Dy()
|
|
|
|
out = rgba.Pix
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|