From 8e1359b45d16ff14e44f013417cc7bf9c8ce4933 Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Sun, 22 Jan 2017 02:49:45 +0100
Subject: [PATCH] flip image in Picture to make it correct

---
 picture.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/picture.go b/picture.go
index ef17326..b1daa77 100644
--- a/picture.go
+++ b/picture.go
@@ -25,6 +25,16 @@ func NewPicture(img image.Image, smooth bool) *Picture {
 	nrgba := image.NewNRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy()))
 	draw.Draw(nrgba, nrgba.Bounds(), img, bounds.Min, draw.Src)
 
+	// flip the image vertically
+	tmp := make([]byte, nrgba.Stride)
+	for i, j := 0, bounds.Dy()-1; i < j; i, j = i+1, j-1 {
+		iSlice := nrgba.Pix[i*nrgba.Stride : (i+1)*nrgba.Stride]
+		jSlice := nrgba.Pix[j*nrgba.Stride : (j+1)*nrgba.Stride]
+		copy(tmp, iSlice)
+		copy(iSlice, jSlice)
+		copy(jSlice, tmp)
+	}
+
 	var texture *pixelgl.Texture
 	mainthread.Call(func() {
 		texture = pixelgl.NewTexture(
-- 
GitLab