Always use IMG_Init() to keep the image libraries resident, since most of the time you'll be loading lots of image.
authorSam Lantinga <slouken@libsdl.org>
Sat, 17 Oct 2009 22:00:12 +0000
changeset 2303766fc378624
parent 229 efaa78b6c2e1
child 231 b31f55bf279a
Always use IMG_Init() to keep the image libraries resident, since most of the time you'll be loading lots of image.
The application should call IMG_Quit() to unload the image libraries.
IMG_jpg.c
IMG_png.c
IMG_tif.c
     1.1 --- a/IMG_jpg.c	Sat Oct 17 21:20:12 2009 +0000
     1.2 +++ b/IMG_jpg.c	Sat Oct 17 22:00:12 2009 +0000
     1.3 @@ -379,7 +379,7 @@
     1.4  	}
     1.5  	start = SDL_RWtell(src);
     1.6  
     1.7 -	if ( IMG_InitJPG() < 0 ) {
     1.8 +	if ( IMG_Init(IMG_INIT_JPG) < 0 ) {
     1.9  		return NULL;
    1.10  	}
    1.11  
    1.12 @@ -394,7 +394,6 @@
    1.13  			SDL_FreeSurface(surface);
    1.14  		}
    1.15  		SDL_RWseek(src, start, SEEK_SET);
    1.16 -		IMG_QuitJPG();
    1.17  		IMG_SetError("JPEG loading error");
    1.18  		return NULL;
    1.19  	}
    1.20 @@ -443,7 +442,6 @@
    1.21  	if ( surface == NULL ) {
    1.22  		lib.jpeg_destroy_decompress(&cinfo);
    1.23  		SDL_RWseek(src, start, SEEK_SET);
    1.24 -		IMG_QuitJPG();
    1.25  		IMG_SetError("Out of memory");
    1.26  		return NULL;
    1.27  	}
    1.28 @@ -458,8 +456,6 @@
    1.29  	lib.jpeg_finish_decompress(&cinfo);
    1.30  	lib.jpeg_destroy_decompress(&cinfo);
    1.31  
    1.32 -	IMG_QuitJPG();
    1.33 -
    1.34  	return(surface);
    1.35  }
    1.36  
     2.1 --- a/IMG_png.c	Sat Oct 17 21:20:12 2009 +0000
     2.2 +++ b/IMG_png.c	Sat Oct 17 22:00:12 2009 +0000
     2.3 @@ -318,7 +318,7 @@
     2.4  	}
     2.5  	start = SDL_RWtell(src);
     2.6  
     2.7 -	if ( IMG_InitPNG() < 0 ) {
     2.8 +	if ( IMG_Init(IMG_INIT_PNG) < 0 ) {
     2.9  		return NULL;
    2.10  	}
    2.11  
    2.12 @@ -497,10 +497,7 @@
    2.13  			SDL_FreeSurface(surface);
    2.14  			surface = NULL;
    2.15  		}
    2.16 -		IMG_QuitPNG();
    2.17  		IMG_SetError(error);
    2.18 -	} else {
    2.19 -		IMG_QuitPNG();
    2.20  	}
    2.21  	return(surface); 
    2.22  }
     3.1 --- a/IMG_tif.c	Sat Oct 17 21:20:12 2009 +0000
     3.2 +++ b/IMG_tif.c	Sat Oct 17 22:00:12 2009 +0000
     3.3 @@ -216,7 +216,7 @@
     3.4  	}
     3.5  	start = SDL_RWtell(src);
     3.6  
     3.7 -	if ( IMG_InitTIF() < 0 ) {
     3.8 +	if ( IMG_Init(IMG_INIT_TIF) < 0 ) {
     3.9  		return NULL;
    3.10  	}
    3.11  
    3.12 @@ -257,7 +257,6 @@
    3.13  		}
    3.14  	}
    3.15  	lib.TIFFClose(tiff);
    3.16 -	IMG_QuitTIF();
    3.17  	
    3.18  	return surface;
    3.19  
    3.20 @@ -266,7 +265,6 @@
    3.21  	if ( surface ) {
    3.22  		SDL_FreeSurface(surface);
    3.23  	}
    3.24 -	IMG_QuitTIF();
    3.25  	return NULL;
    3.26  }
    3.27