always convert image in NewPicture (Bounds)
@@ -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()))
+ 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() {
