Source code of a sample program generating a pseudo-random map and drawing it using the descibed method: http://svgames.pl/trash/autotiles.zip
Uses SDL, SDL_image, OpenGL and Sour (included).