@@ -327,7 +327,8 @@ bool locator::operator<(const locator& a) const
327327// Load overlay image and compose it with the original surface.
328328static void add_localized_overlay (const std::string& ovr_file, surface& orig_surf)
329329{
330- surface ovr_surf = IMG_Load_IO (SDL_IOFromFile (ovr_file.c_str (), " rb" ), true );
330+ SDL_IOStream* stream = SDL_IOFromFile (ovr_file.c_str (), " rb" );
331+ surface ovr_surf = IMG_Load_IO (stream, true );
331332 if (!ovr_surf) {
332333 return ;
333334 }
@@ -365,7 +366,8 @@ static surface load_image_file(const image::locator& loc)
365366 location = loc_location.value ();
366367 }
367368
368- res = IMG_Load_IO (SDL_IOFromFile (location.value ().c_str (), " rb" ), true );
369+ SDL_IOStream* stream = SDL_IOFromFile (location.value ().c_str (), " rb" );
370+ res = IMG_Load_IO (stream, true );
369371
370372 // If there was no standalone localized image, check if there is an overlay.
371373 if (res && !loc_location) {
@@ -925,14 +927,16 @@ save_result save_image(const surface& surf, const std::string& filename)
925927 if (boost::algorithm::ends_with (filename, " .jpeg" ) || boost::algorithm::ends_with (filename, " .jpg" ) || boost::algorithm::ends_with (filename, " .jpe" )) {
926928 LOG_IMG << " Writing a JPG image to " << filename;
927929
928- const int err = IMG_SaveJPG_IO (surf, SDL_IOFromFile (filename.c_str (), " rb" ), true , 75 );
930+ SDL_IOStream* stream = SDL_IOFromFile (filename.c_str (), " rb" );
931+ const int err = IMG_SaveJPG_IO (surf, stream, true , 75 );
929932 return err == 0 ? save_result::success : save_result::save_failed;
930933 }
931934
932935 if (boost::algorithm::ends_with (filename, " .png" )) {
933936 LOG_IMG << " Writing a PNG image to " << filename;
934937
935- const int err = IMG_SavePNG_IO (surf, SDL_IOFromFile (filename.c_str (), " rb" ), true );
938+ SDL_IOStream* stream = SDL_IOFromFile (filename.c_str (), " rb" );
939+ const int err = IMG_SavePNG_IO (surf, stream, true );
936940 return err == 0 ? save_result::success : save_result::save_failed;
937941 }
938942
0 commit comments