#ifndef _CIMAGE_HPP_
#define _CIMAGE_HPP_

/*** SDL Header Files ***/
#include <SDL.h> 
#include <SDL_image.h> 

/*** DLL Header File ***/
#include "dllExport.h"

/*** Custom Header Files ***/
#include "../UtilityEngine/cString.hpp"

using UtilityEngine::cString;

namespace VideoEngine {
	class EXPORT_FROM_MYDLL cImage
	{
	public:
		cImage( const cString& dir = "", const cString& filename = "", const bool transparent = false, 
			const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255,
			const unsigned char translevel = 255);
		cImage( SDL_Surface* surface );
		cImage( SDL_Texture* texture );
		/* Copy constructor */
		cImage( const cImage& copy, const bool surfaceCopy = true );
		~cImage();

		/* Saves the Image to a BMP file */
		void SaveImage( const cString& fileName, const cString& dir = "" );
		/* Creates a New Image based on input */
		const cImage* NewImage( SDL_Rect& area ) const;
		
		///Sets
		/* Sets the Directory of the image */
		void setDir( const cString& dir );
		/* Sets the File Name of the image */
		void setFileName( const cString& filename );
		/* Sets the File Name and the Directory of the image */
		void setFileNameandDir( const cString& filename, const cString& dir = "" );

		/* Sets Transparent on if set to true */
		void setTransparent( const bool transparent = true );
		/* Sets the colour to be made transparent */
		void setColourTrans( const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255 );
		/* Sets the level of the transparent 255 = clear, 0 = solid */
		void setLevelTrans( const unsigned char translevel = 255 );
		
		///Gets
		/* Gets a pointer to the SDL_Surface */
		SDL_Surface* getSurface() const;
		/* Gets a pointer to the SDL_Texture */
		SDL_Texture* getImage() const;
		/* Gets the width of the image */
		const unsigned long int getWidth() const;
		/* Gets the Height of the image */
		const unsigned long int getHeight() const;
		/* Gets the Width and Height of the image */
		const SDL_Rect getWH() const;
		/* Gets the Width and Height of the image */
		void getWH( unsigned long int& w, unsigned long int& h ) const;

		/* Gets the Directory of the image */
		const cString getDir() const;
		/* Gets the File Name of the image */
		const cString getFileName() const;

		/* Gets return true if transparent on false if off */
		const bool getTransparent() const;
		/* Gets return the colour to be made transparent */
		void getColourTrans( unsigned char& red, unsigned char& blue, unsigned char& green ) const;
		/* Gets the transparent red colour */
		const unsigned char getRedTrans() const;
		/* Gets the transparent blue colour */
		const unsigned char getBlueTrans() const;
		/* Gets the transparent green colour */
		const unsigned char getGreenTrans() const;
		/* Gets the transparent level 255 = clear, 0 = solid */
		const unsigned char getLevelTrans() const;

	protected:
		/* Protected so only derived class can access. *.
		/* Sets the image to surface */
		void setImage( SDL_Surface* surface );
		void setImage( SDL_Texture* texture );

	private:
		///Functions
		void TransparentSetup();
		virtual void LoadImage();	//cFont over rides this
		void UnloadImage();
		
	private:
		///Variables
		SDL_Texture* mp_texture;// = nullptr
		
		cString m_dir;// = ""
		cString m_fileName;// = ""

		//char m_dir[255];
		//char m_fileName[255];
		
		bool m_transparent;// = false
		
		unsigned char m_transRed;// = 0
		unsigned char m_transBlue;// = 0
		unsigned char m_transGreen;// = 255
		
		unsigned char m_transLevel;// = 255	
	};/// END CLASS DEFINITION cImage
}/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CIMAGE_HPP_
