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.
|
||||
func NewPicture(img image.Image, smooth bool) *Picture {
|
||||
// convert the image to RGBA format
|
||||
var rgba *image.RGBA
|
||||
if rgbaImg, ok := img.(*image.RGBA); ok {
|
||||
// convert the image to NRGBA format
|
||||
var rgba *image.NRGBA
|
||||
if rgbaImg, ok := img.(*image.NRGBA); ok {
|
||||
rgba = rgbaImg
|
||||
} 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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue