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.
|
// 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 NRGBA format
|
// convert the image to NRGBA format
|
||||||
var nrgba *image.NRGBA
|
nrgba := image.NewNRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()))
|
||||||
if nrgbaImg, ok := img.(*image.NRGBA); ok {
|
draw.Draw(nrgba, nrgba.Bounds(), img, img.Bounds().Min, draw.Src)
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
var texture *pixelgl.Texture
|
var texture *pixelgl.Texture
|
||||||
mainthread.Call(func() {
|
mainthread.Call(func() {
|
||||||
|
|
Loading…
Reference in New Issue