fix - convert image in Picture to NRGBA, not RGBA

This commit is contained in:
faiface 2017-01-20 19:25:26 +01:00
parent 37baaee464
commit e34970d541
1 changed files with 4 additions and 4 deletions

View File

@ -20,12 +20,12 @@ type Picture struct {
// NewPicture creates a new picture from an image.Image. // NewPicture creates a new picture from an image.Image.
func NewPicture(img image.Image, smooth bool) *Picture { func NewPicture(img image.Image, smooth bool) *Picture {
// convert the image to RGBA format // convert the image to NRGBA format
var rgba *image.RGBA var rgba *image.NRGBA
if rgbaImg, ok := img.(*image.RGBA); ok { if rgbaImg, ok := img.(*image.NRGBA); ok {
rgba = rgbaImg rgba = rgbaImg
} else { } else {
rgba = image.NewRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy())) rgba = image.NewNRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()))
draw.Draw(rgba, rgba.Bounds(), img, img.Bounds().Min, draw.Src) draw.Draw(rgba, rgba.Bounds(), img, img.Bounds().Min, draw.Src)
} }