flip image in Picture to make it correct
This commit is contained in:
parent
ca9b2716a8
commit
8e1359b45d
10
picture.go
10
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(
|
||||
|
|
Loading…
Reference in New Issue