From f6ed7c9db5b634d906e9c3802e456ae59b92f6fd Mon Sep 17 00:00:00 2001 From: faiface Date: Thu, 29 Mar 2018 16:18:37 +0200 Subject: [PATCH] fix mutating *image.RGBA when converting PictureDataFromImage --- data.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/data.go b/data.go index c941241..a3d0b26 100644 --- a/data.go +++ b/data.go @@ -165,13 +165,8 @@ func verticalFlip(rgba *image.RGBA) { // // The resulting PictureData's Bounds will be the equivalent of the supplied image.Image's Bounds. func PictureDataFromImage(img image.Image) *PictureData { - var rgba *image.RGBA - if rgbaImg, ok := img.(*image.RGBA); ok { - rgba = rgbaImg - } else { - rgba = image.NewRGBA(img.Bounds()) - draw.Draw(rgba, rgba.Bounds(), img, img.Bounds().Min, draw.Src) - } + rgba := image.NewRGBA(img.Bounds()) + draw.Draw(rgba, rgba.Bounds(), img, img.Bounds().Min, draw.Src) verticalFlip(rgba)