Skip to content

Commit

Permalink
sdl/surface: fix []byte length calculation in Pixels() to use pitch m…
Browse files Browse the repository at this point in the history
…ultiplied by height

Signed-off-by: Lilis Iskandar <[email protected]>
  • Loading branch information
veeableful committed May 2, 2021
1 parent 0609645 commit 8f453f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sdl/surface.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (surface *Surface) BytesPerPixel() int {
// Pixels returns the actual pixel data of the surface.
func (surface *Surface) Pixels() []byte {
var b []byte
length := int(surface.W*surface.H) * int(surface.Format.BytesPerPixel)
length := int(surface.H) * int(surface.Pitch)
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b))
sliceHeader.Cap = int(length)
sliceHeader.Len = int(length)
Expand Down

0 comments on commit 8f453f7

Please sign in to comment.