title: Loading images using custom function fails in SDL
body: <p>My script is failing to run, as it opens a window then closes it. It fails at file loading. The script works on my laptop but not my desktop PC, and all of the neccecary files are there. It's to do with this function;</p>
  
  <p>This is my function <code>load_image()</code>;</p>
  
  <pre><code>SDL_Surface *load_image( std::string filename )
  {
      //The image that's loaded
      SDL_Surface* loadedImage = NULL;
  
      //The optimized surface that will be used
      SDL_Surface* optimizedImage = NULL;
  
      //Load the image
      loadedImage = IMG_Load( filename.c_str() );
  
      //If the image loaded
      if( loadedImage != NULL )
      {
          //Create an optimized surface
          optimizedImage = SDL_DisplayFormatAlpha( loadedImage );
  
          //Free the old surface
          SDL_FreeSurface( loadedImage );
  
          //If the surface was optimized
          if( optimizedImage != NULL )
          {
              //Color key surface
              SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage-&gt;format, 0, 0xFF, 0xFF ) );
          }
      }
  
      //Return the optimized surface
      return optimizedImage;
  
  }
  </code></pre>
  
  <p>And I call it like this;</p>
  
  <pre><code>sprite = load_image( "sprites.png" );
  
  if( sprite == NULL )
  {
      return false;
  }
  </code></pre>
  
  <p>The only problem is, it always returns false, EVEN THOUGH the file is in there. The problem is, this code doesn't return false on my laptop!</p>