Hey.
I've got a function that loads an image using SDL. I'm getting the exception below at the commented line:
bool Draw_Engine::Load_Image(Image& image)
{
//Free up the previous image if there was one
if(image.Get_Surface() != NULL)
Free_Image(image);
SDL_Surface* loaded_image = NULL;
SDL_Surface* optimized_image = NULL;
loaded_image = IMG_Load(image.Get_File_Name().c_str());
// If the image was loaded successfully, try to optimize it.
if(loaded_image != NULL) {
optimized_image = SDL_DisplayFormat(loaded_image); // THIS LINE
SDL_FreeSurface(loaded_image);
//If the image was optimized just fine
if(optimized_image != NULL && image.Is_Colour_Key()) {
// Create the colour key
colour_key = SDL_MapRGB(optimized_image->format, image.Get_Red(), image.Get_Blue(), image.Get_Green());
// Sets the colour key to the image
SDL_SetColorKey(optimized_image, SDL_RLEACCEL | SDL_SRCCOLORKEY, colour_key);
}
// Set the image's surface to the newly optimized surface
image.Set_Surface(optimized_image);
}
// Otherwise return false.
else
return false;
return true;
}
Quote:Unhandled exception at 0x1002b195 in Ghost.exe: 0xC0000005: Access violation reading location 0x0000013c.
Just wondering what could possibly cause such an exception?
loaded_image has these data values when the exception is thrown: