[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.2 IMG_Load_RW

SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc)

src
The source SDL_RWops as a pointer. The image is loaded from this.
freesrc
A non-zero value mean is will automatically close/free the src for you.

Load src for use as a surface. This can load all supported image formats, except TGA. Using SDL_RWops is not covered here, but they enable you to load from almost any source.
Note: If the image format loader requires initialization, it will attempt to do that the first time it is needed if you have not already called IMG_Init to load support for your image format.
Note: If the image format supports a transparent pixel, SDL_image will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling:
SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);

Returns: a pointer to the image as a new SDL_Surface. NULL is returned on errors.

 
// load sample.png in to image
SDL_Surface *image;
image=IMG_Load_RW(SDL_RWFromFile("sample.png", "rb"), 1);
if(!image) {
    printf("IMG_Load_RW: %s\n", IMG_GetError());
    // handle error
}

See Also:
3.1.2 IMG_Init, 3.2.1 IMG_Load, 3.2.3 IMG_LoadTyped_RW



This document was generated on November, 3 2009 using texi2html