fix bug in PictureDataFromImage
This commit is contained in:
parent
0644103ba1
commit
b1311c29b6
10
data.go
10
data.go
|
@ -160,11 +160,13 @@ func verticalFlip(nrgba *image.NRGBA) {
|
||||||
//
|
//
|
||||||
// The resulting PictureData's Bounds will be the equivalent of the supplied image.Image's Bounds.
|
// The resulting PictureData's Bounds will be the equivalent of the supplied image.Image's Bounds.
|
||||||
func PictureDataFromImage(img image.Image) PictureData {
|
func PictureDataFromImage(img image.Image) PictureData {
|
||||||
nrgba := image.NewNRGBA(image.Rect(
|
var nrgba *image.NRGBA
|
||||||
0, 0,
|
if img, ok := img.(*image.NRGBA); ok {
|
||||||
img.Bounds().Dx(), img.Bounds().Dy(),
|
nrgba = img
|
||||||
))
|
} else {
|
||||||
|
nrgba = image.NewNRGBA(img.Bounds())
|
||||||
draw.Draw(nrgba, nrgba.Bounds(), img, img.Bounds().Min, draw.Src)
|
draw.Draw(nrgba, nrgba.Bounds(), img, img.Bounds().Min, draw.Src)
|
||||||
|
}
|
||||||
|
|
||||||
verticalFlip(nrgba)
|
verticalFlip(nrgba)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue