fix Picture creation optimization
This commit is contained in:
parent
b15253ee83
commit
b86e04704f
|
@ -22,8 +22,8 @@ type Picture struct {
|
||||||
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 RGBA format
|
||||||
var rgba *image.RGBA
|
var rgba *image.RGBA
|
||||||
if img, ok := img.(*image.RGBA); ok {
|
if rgbaImg, ok := img.(*image.RGBA); ok {
|
||||||
rgba = img
|
rgba = rgbaImg
|
||||||
} else {
|
} else {
|
||||||
rgba = image.NewRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()))
|
rgba = image.NewRGBA(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