#pragma once
#include <windows.h>
#include "ByteArray.h"

const byte TGA_TYPE_NOIMAGE				= 0; // No Image Data Included
const byte TGA_TYPE_UNCOMP_COLORMAP		= 1; // Uncompressed, Color-mapped Image
const byte TGA_TYPE_UNCOMP_RGB			= 2; // Uncompressed, True-color Image (war3 standard)
const byte TGA_TYPE_UNCOMP_BW			= 3; // Uncompressed, Black-and-white Image
const byte TGA_TYPE_RLE_COLORMAP		= 9; // Run-length encoded, Color-mapped Image
const byte TGA_TYPE_RLE_RGB				= 10; // Run-length encoded, True-color Image
const byte TGA_TYPE_RLG_BW				= 11; // Run-length encoded, Black-and-white Image
const byte TGA_IMG_STARTS_BOTTOM_LEFT	= 0x00;//bottom left
const byte TGA_IMG_STARTS_BOTTOM_RIGHT	= 0x10;//bottom right
const byte TGA_IMG_STARTS_TOP_LEFT		= 0x20;//top left
const byte TGA_IMG_STARTS_TOP_RIGHT		= 0x30;//top right
const byte TGA_IMG_WAR3_FORMAT			= 0x28; // war3 image origin and alpha channel bit
const int TGA_MAX_WIDTH					= 32768;
const int TGA_MAX_HEIGHT				= 32768;

const char STR_TRUEVISION[] = "\0\0\0\0\0\0\0\0TRUEVISION-XFILE Generated by W3Z Map Editor";
const int STR_TRUEVISION_LEN = strlen(STR_TRUEVISION);

class CTarga  
{
public:
	CByteArray m_baUnsupportedBuffer;
	byte* GetBitmapPtr();
	int GetHeight();
	int GetWidth();
	void SetSize(int width, int height);
	CTarga();
	virtual ~CTarga();
protected:
// Image Data
	byte* m_pBitmap;
// Color Map Data
	byte* m_pColorMap;
// Image ID 
	byte* m_pImageID;
// Image Spec 10 bytes
	byte m_ImgDesc;
	byte m_PixelDepth;
	short m_Height;
	short m_Width;
	short m_YOrg;
	short m_XOrg;
//	Color Map Spec 5 bytes
	byte m_ColorMapEntrySize;
	short m_ColorMapLength;
	short m_FirstEntryIndex;
//
	byte m_ImageType;
	byte m_ColorMapType;
	byte m_IDLength;
};