From b98c85137a55ed861b4b67883dbdd1d24ce6b15c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Oct 2009 22:00:12 +0000 Subject: [PATCH] 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 | 6 +----- IMG_png.c | 5 +---- IMG_tif.c | 4 +--- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/IMG_jpg.c b/IMG_jpg.c index 2aa59235..98337c7b 100644 --- a/IMG_jpg.c +++ b/IMG_jpg.c @@ -379,7 +379,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) } start = SDL_RWtell(src); - if ( IMG_InitJPG() < 0 ) { + if ( IMG_Init(IMG_INIT_JPG) < 0 ) { return NULL; } @@ -394,7 +394,6 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) SDL_FreeSurface(surface); } SDL_RWseek(src, start, SEEK_SET); - IMG_QuitJPG(); IMG_SetError("JPEG loading error"); return NULL; } @@ -443,7 +442,6 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) if ( surface == NULL ) { lib.jpeg_destroy_decompress(&cinfo); SDL_RWseek(src, start, SEEK_SET); - IMG_QuitJPG(); IMG_SetError("Out of memory"); return NULL; } @@ -458,8 +456,6 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) lib.jpeg_finish_decompress(&cinfo); lib.jpeg_destroy_decompress(&cinfo); - IMG_QuitJPG(); - return(surface); } diff --git a/IMG_png.c b/IMG_png.c index bf0deb9b..f00af1ce 100644 --- a/IMG_png.c +++ b/IMG_png.c @@ -318,7 +318,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) } start = SDL_RWtell(src); - if ( IMG_InitPNG() < 0 ) { + if ( IMG_Init(IMG_INIT_PNG) < 0 ) { return NULL; } @@ -497,10 +497,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) SDL_FreeSurface(surface); surface = NULL; } - IMG_QuitPNG(); IMG_SetError(error); - } else { - IMG_QuitPNG(); } return(surface); } diff --git a/IMG_tif.c b/IMG_tif.c index da0d8078..a9f5511b 100644 --- a/IMG_tif.c +++ b/IMG_tif.c @@ -216,7 +216,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src) } start = SDL_RWtell(src); - if ( IMG_InitTIF() < 0 ) { + if ( IMG_Init(IMG_INIT_TIF) < 0 ) { return NULL; } @@ -257,7 +257,6 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src) } } lib.TIFFClose(tiff); - IMG_QuitTIF(); return surface; @@ -266,7 +265,6 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src) if ( surface ) { SDL_FreeSurface(surface); } - IMG_QuitTIF(); return NULL; }