Skip to content

Commit

Permalink
Always use IMG_Init() to keep the image libraries resident, since mos…
Browse files Browse the repository at this point in the history
…t of the time you'll be loading lots of image.

The application should call IMG_Quit() to unload the image libraries.
  • Loading branch information
slouken committed Oct 17, 2009
1 parent f52034b commit b98c851
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
6 changes: 1 addition & 5 deletions IMG_jpg.c
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand Down
5 changes: 1 addition & 4 deletions IMG_png.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions IMG_tif.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -257,7 +257,6 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
}
}
lib.TIFFClose(tiff);
IMG_QuitTIF();

return surface;

Expand All @@ -266,7 +265,6 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
if ( surface ) {
SDL_FreeSurface(surface);
}
IMG_QuitTIF();
return NULL;
}

Expand Down

0 comments on commit b98c851

Please sign in to comment.