fix - convert image in Picture to NRGBA, not RGBA
This commit is contained in:
parent
37baaee464
commit
e34970d541
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue