I'm having a problem loading PNG images on the WIZ with SDL. Can anyone spot anything wrong with this code? It worked before on WinXP/Linux.
Here is the image loader function:
This is how I'm trying to load the image:
The WIZ just hangs on the "Loading..." screen. I checked it on the PC and the error file says it failed to load the image. The image of course is present. I can change it to a .bmp file and it works perfect.
Any ideas why it won't work with PNG files?
Here is the image loader function:
Code:
SDL_Surface* LoadImage(char* file_name) {
/* Temporary storage for the image that is loaded. */
SDL_Surface* loaded_image = NULL;
/* The optimized image that will be used. */
SDL_Surface* optimized_image = NULL;
/* Load the image. */
loaded_image = IMG_Load(file_name);
/* Create an optimized image if nothing went wrong in loading the
image. */
if (loaded_image != NULL) {
optimized_image = SDL_DisplayFormat(loaded_image);
Uint32 colorkey = SDL_MapRGB(optimized_image->format, 255, 0, 255);
/* Set all pixels of colorkey color to be transparent. */
SDL_SetColorKey(optimized_image, SDL_SRCCOLORKEY, colorkey);
/* Free the original image. */
SDL_FreeSurface(loaded_image);
}
/* Return the optimized image. */
return optimized_image;
}
Code:
player = LoadImage("test.png");
if (player == NULL) {
printf("Error loading player image!\n");
return;
}
Any ideas why it won't work with PNG files?