Skip to content

Instantly share code, notes, and snippets.

@jrenner
Created September 21, 2012 04:14
Show Gist options
  • Save jrenner/3759689 to your computer and use it in GitHub Desktop.
Save jrenner/3759689 to your computer and use it in GitHub Desktop.
Can't convert unsafe.Pointer to int
func getPixel(surface *sdl.Surface, x, y int) uint32 {
var bpp uint8 = surface.Format.BytesPerPixel
/* Here p is the address to the pixel we want to retrieve */
var p *uint32 = *uint32(int(surface.Pixels) + y*int(surface.Pitch) + x*bpp)
return *p
return 1 /* shouldn't happen, but avoids warnings */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment