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

3.1.2 IMG_Init

int IMG_Init(int flags)

flags
bitwise OR'd set of image formats to support by loading a library now. The values you may OR together to pass in are:
IMG_INIT_JPG
IMG_INIT_PNG
IMG_INIT_TIF

Initialize by loading support as indicated by the flags, or at least return success if support is already loaded. You may call this multiple times, which will actually require you to call IMG_Quit just once to clean up. You may call this function with a 0 to retrieve whether support was built-in or not loaded yet.
Note: to load JPG, PNG, and/or TIF images you can call IMG_Init with the right IMG_INIT_* flags OR'd together before you program gets busy, to prevent a later hiccup while it loads the library, and to check that you do have the support that you need before you try and use it.
Note: No initialization is needed nor performed when using the IMG_isJPG, IMG_isPNG, and IMG_isTIF functions.
Note: this function does not always set the error string, so do not depend on IMG_GetError being meaningful all the time.

Returns: a bitmask of all the currently initted image loaders.

 
// load support for the JPG and PNG image formats
int flags=IMG_INIT_JPG|IMG_INIT_PNG;
int initted=IMG_Init(flags);
if((initted&flags) != flags) {
    printf("IMG_Init: Failed to init required jpg and png support!\n");
    printf("IMG_Init: %s\n", IMG_GetError());
    // handle error
}

See Also:
3.1.3 IMG_Quit



This document was generated on November, 3 2009 using texi2html