always convert image in NewPicture (Bounds)

This commit is contained in:
faiface 2017-01-20 22:46:18 +01:00
parent 1f4f11078b
commit 5daaad80dc
1 changed files with 2 additions and 7 deletions

View File

@ -21,13 +21,8 @@ type Picture struct {
// NewPicture creates a new picture from an image.Image.
func NewPicture(img image.Image, smooth bool) *Picture {
// convert the image to NRGBA format
var nrgba *image.NRGBA
if nrgbaImg, ok := img.(*image.NRGBA); ok {
nrgba = nrgbaImg
} else {
nrgba = image.NewNRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()))
draw.Draw(nrgba, nrgba.Bounds(), img, img.Bounds().Min, draw.Src)
}
nrgba := image.NewNRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()))
draw.Draw(nrgba, nrgba.Bounds(), img, img.Bounds().Min, draw.Src)
var texture *pixelgl.Texture
mainthread.Call(func() {