I want to blit a sprite to a surface using Haskell’s SDL binding, but I don’t know how to define the transparent color in the sprite’s surface. Here is the code so far:
module Main where
import Graphics.UI.SDL as SDL
import Graphics.UI.SDL.Image as SDLi
main = do
SDL.init [SDL.InitVideo]
screen <- SDL.setVideoMode 500 500 32 []
SDL.fillRect screen Nothing (SDL.Pixel 0x00FFFFFF)
ball <- SDLi.load "30ball.png"
SDL.blitSurface ball Nothing screen Nothing
SDL.flip screen
delay 2000
SDL.quit
In the Sdldotnet-Library, I could set the properties of ball with something like:
ball.Transparent<-true
ball.TransparentColor<-Color.FromArgb (0, 255, 0)
Any idea how I can achieve the same in Haskell’s SDL binding?

Here is the working version after implementing Banthar’s advice:
module Main where
import Graphics.UI.SDL as SDL
import Graphics.UI.SDL.Image as SDLi
main = do
SDL.init [SDL.InitVideo]
screen <- SDL.setVideoMode 500 500 32 []
SDL.fillRect screen Nothing (SDL.Pixel 0x00FFFFFF)
ball <- SDLi.load "30ball.bmp"
b2 <- convertSurface ball (surfaceGetPixelFormat screen) []
t <- mapRGB (surfaceGetPixelFormat b2) 0 255 0
setColorKey b2 [SrcColorKey, RLEAccel] t
SDL.blitSurface b2 Nothing screen Nothing
SDL.flip screen
delay 2000
SDL.quit
Try setColorKey. You can find more info here. If you are using PNGs the simplest way is to use alpha channel.