From b1311c29b6ef988ea56911292a651ae476f75324 Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Wed, 1 Mar 2017 12:34:30 +0100
Subject: [PATCH] fix bug in PictureDataFromImage

---
 data.go | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/data.go b/data.go
index 035e80d..5cb1d6d 100644
--- a/data.go
+++ b/data.go
@@ -160,11 +160,13 @@ func verticalFlip(nrgba *image.NRGBA) {
 //
 // The resulting PictureData's Bounds will be the equivalent of the supplied image.Image's Bounds.
 func PictureDataFromImage(img image.Image) PictureData {
-	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 nrgba *image.NRGBA
+	if img, ok := img.(*image.NRGBA); ok {
+		nrgba = img
+	} else {
+		nrgba = image.NewNRGBA(img.Bounds())
+		draw.Draw(nrgba, nrgba.Bounds(), img, img.Bounds().Min, draw.Src)
+	}
 
 	verticalFlip(nrgba)
 
-- 
GitLab