Loading Images

function SDL_LoadBMP(filename: PChar): PSDL_Surface;

This function creates a surface of the appropriate dimensions and loads a .bmp file into it. The function returns the new surface, or nil if there was an error (not null as stated in the documentation). The function is straightforward to use:

  BMPFile : PChar = 'MyBMP.bmp';
  Image : PSDL_Surface;
   Image := SDL_LoadBMP(BMPFile);        

You can load other types of image such as .jpg and .png with the IMG_LOAD function if you use the additional dynamic link library SDL_image.dll and its header file. See Chapter 3a of Freepascal meets SDL.

Programming - a skill for life!

Descriptions and demonstrations of SDL procedures and functions