Tao.Sdl SDK Documentation

SdlImage.IMG_Load Method 

Load from a file.

[Visual Basic]
Public Shared Function IMG_Load( _
   ByVal file As String _
) As IntPtr
[C#]
public static IntPtr IMG_Load(
   string file
);

Parameters

file
Image file name to load a surface from.

Return Value

a pointer to the image as a new SDL_Surface. NULL is returned on errors, such as no support built for the image, or a file reading error.

Remarks

Load file for use as an image in a new surface. This actually calls IMG_LoadTyped_RW, with the file extension used as the type string. This can load all supported image files, including TGA as long as the filename ends with ".tga". It is best to call this outside of event loops, and rather keep the loaded images around until you are really done with them, as disk speed and image conversion to a surface is not that speedy. Don't forget to SDL_FreeSurface the returned surface pointer when you are through with it.

Binds to C-function in SDL_image.h

            SDL_Surface *IMG_Load(const char *file)
            

Example

            // load sample.png into image
                    SDL_Surface *image;
                    image=IMG_Load("sample.png");
                    if(!image)
                {
                    printf("IMG_Load: %s\n", IMG_GetError());
                    // handle error
                }
            

See Also

SdlImage Class | Tao.Sdl Namespace | IMG_Load_RW | IMG_LoadTyped_RW