/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
------------------------------------------------------------------------------*/


#ifndef	__NPICTUREIO__
#define	__NPICTUREIO__


		#include "picture/pict_io_codec.h"
		#include "memory/singleton.h"
		#include "container/nlist.h"


namespace GS {

/*
	@short	Picture I/O class.
	@author Emmanuel Julien (ejulien@nworks.fr)
*/
class	PictureIO : public Singleton <PictureIO>
{
		AutoList <PictureCodec *> codec_list;

public:

		/*!
			@short	Generic load function.
			This function try to load a given resource using all registered
			codec. This is a convenience function and is not designed to be
			fast. If you know the file format you are working with then please
			directly use the appropriate codec.
		*/
		bool			Load(Picture &, const char *uri);
		/// Save a picture through a given codec.
		bool			Save(const Picture &, const char *uri, const char *codec_name);

		/// Return a codec from its ID or the file extension it supports.
		PictureCodec	*Codec(const char *codec_name);

		/// Register an I/O codec inside the manager.
		bool			RegisterCodec(PictureCodec *, bool verbose = false);

		/// Delete all registered codec.
		void			DeleteCodecs() { codec_list.Clear(); }

		/// Load a BMP resource via the core codec.
		bool			BmpLoad(Picture &, IO::Handle &);
		/*!
			@short	Load a TARGA (TGA) resource via the core codec.
			@note	Supported color format are BGRA8/BGR8/RGB24/RGB555
					both RLE and RAW.
		*/
		bool			TgaLoad(Picture &, IO::Handle &);
		/*!
			@short	Save a picture to TARGA (TGA) via the core codec.
			@note	Supported color format are BGRA8/BGR8/RGB24/RGB555.
		*/
		bool			TgaSave(const Picture &, const char *uri);
};

} // GS


#endif	// __NPICTUREIO__

