#include "SDL.h"
#include "SDL_image.h"

char *files[]={
	"lena.bmp", "BMP",
	"lena.gif", "GIF",
	"lena.jpg", "JPG",
	"lena.lbm", "LBM",
	"lena.pcx", "PCX",
	"lena.png", "PNG",
	"lena.pnm", "PNM",
	"lena.tga", "TGA",
	"lena.tif", "TIF",
	"lena.xcf", "XCF",
	"lena.xpm", "XPM",
	NULL,
	"lena.xbm", "XBM",
	NULL
};

int main(int argc, char **argv)
{
	SDL_Surface *image;
	int i;
	
	/* check arguments */
	if(argc!=1)
	{
		printf("%s (no arguments)\n",*argv);
		return 1;
	}

	/* startup SDL */
	if(SDL_Init(SDL_INIT_VIDEO)==-1)
	{
		printf("SDL_Init: %s\n", SDL_GetError());
		return 1;
	}

	for(i=0; files[i]; i+=2)
	{
		/* load the image */
		image=IMG_Load(files[i]);
		if(!image)
		{
			/* image failed to load */
			printf("IMG_Load: %s\n", IMG_GetError());
			printf("%s is not supported, or the image data is corrupted\n", files[i+1]);
			files[i+1]=NULL;
			continue;
		}
		/* report success */
		printf("%s is supported\n", files[i+1]);
		/* free the loaded image */
		SDL_FreeSurface(image);
	}

	/* shutdown SDL */
	SDL_Quit();

	return 0;
}
