#pragma once

#include "Proxies.hpp"

namespace Proxies {

	struct TargaHeader {
		unsigned char
			idLength,
			colorMapType,
			imageType,
			indexLow,
			indexHigh,
			lengthLow,
			lengthHigh,
			colorEntrySize,
			xOriginLow,
			xOriginHigh,
			yOriginLow,
			yOriginHigh,
			widthLow,
			widthHigh,
			heightLow,
			heightHigh,
			pixelSize,
			flags;

		enum {
			RGB=2,
			RLERGB=10,
			XReversed=16,
			YReversed=32
		};

	};

	struct TargaColor
	{
		BYTE
			blue,
			green,
			red;
	};

	struct TargaColorA
	{
		BYTE
			blue,
			green,
			red,
			alpha;
	};

	void
		WriteTargaFile(
			const char* filename,
			int width,
			int height,
			Stuff::DynamicArrayOf<TargaColor> &data
		);

	void
		WriteTargaFile(
			const char* filename,
			int width,
			int height,
			Stuff::DynamicArrayOf<TargaColorA> &data
		);

	void
		ReadTargaHeader(
			TargaHeader *header,
			Stuff::MemoryStream *file,
			int *width,
			int *height,
			unsigned *red_depth,
			unsigned *green_depth,
			unsigned *blue_depth,
			unsigned *alpha_depth
		);

	void
		ReadTargaChannels(
			Stuff::MemoryStream *file,
			TargaHeader *header,
			Stuff::DynamicArrayOf<TargaColor> *data
		);

	void
		ReadTargaChannels(
			Stuff::MemoryStream *file,
			TargaHeader *header,
			Stuff::DynamicArrayOf<TargaColorA> *data
		);

}
