fix cursor index out of range error.

This commit is contained in:
Miroslav Šedivý 2021-03-25 11:59:57 +01:00
parent bf6181764b
commit 5d00e0bdbd

View File

@ -246,11 +246,11 @@ func GetCursorImage() *types.CursorImage {
pixels := C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width*height*8)) pixels := C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width*height*8))
img := image.NewRGBA(image.Rect(0, 0, width, height)) img := image.NewRGBA(image.Rect(0, 0, width, height))
for row := 0; row < height; row++ { for y := 0; y < height; y++ {
for col := 0; col < width; col++ { for x := 0; x < width; x++ {
pos := ((row * height) + col) * 8 pos := ((y * width) + x) * 8
img.SetRGBA(col, row, color.RGBA{ img.SetRGBA(x, y, color.RGBA{
A: pixels[pos+3], A: pixels[pos+3],
R: pixels[pos+2], R: pixels[pos+2],
G: pixels[pos+1], G: pixels[pos+1],