always convert image in NewPicture (Bounds)
This commit is contained in:
parent
1f4f11078b
commit
5daaad80dc
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue