[Haskell-beginners] Reading pixels in Haskell SDL

han e at xtendo.org
Tue Feb 9 17:55:13 EST 2010

I'm using SDL (http://hackage.haskell.org/packages/archive/SDL/0.5.9/doc/html/Graphics-UI-SDL.html)

As far as I know, in the original SDL for C, reading and writing
pixels on a surface is done by accessing pointer + y * width + x. In
Pygame, since Python has no such thing as pointer, they have get_at
and set_at function for this task. I thought there would be something
equivalent in Haskell SDL, but couldn't find any.

For writing pixels on the Surface, I've found a couple of functions:


However, I can't find one that reads.

looks like the one, but I have no idea how I can use it, since it
returns Pixels which is defined as:

	data PixelsData
	type Pixels = Ptr PixelsData

I want to read a pixel at (x, y) of a Surface. Does anyone know how?

More information about the Beginners mailing list