#ifndef GFX_IMAGE_PIXELFORMAT_INDEXED_H__
#define GFX_IMAGE_PIXELFORMAT_INDEXED_H__


#include "maxon/gfx_image_pixelformat.h"

namespace maxon
{

/// @addtogroup Graphics
/// @{

//----------------------------------------------------------------------------------------
/// PixelFormatIndexedColorInterface extends the PixelFormatInterface with the ability to handle color palettes/tables.
//----------------------------------------------------------------------------------------
class PixelFormatIndexedColorInterface : MAXON_INTERFACE_BASES(PixelFormatInterface)
{
	MAXON_INTERFACE(PixelFormatIndexedColorInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.image.interface.pixelformatindexedcolor", MAXON_IMPLEMENTATION_MODULE("net.maxon.image"));

public:
	//----------------------------------------------------------------------------------------
	/// Initialize the pixel format with a specific number of color entries and a given pixel format for the color entries.
	/// @param[in] count							Number of color entries in the table.
	/// @param[in] srcFormatPtr				Pixel format of the color entries.
	/// @return												OK on success.
	//----------------------------------------------------------------------------------------
	MAXON_METHOD Result<void> InitColorTable(Int count, const PixelFormat& srcFormatPtr);

	//----------------------------------------------------------------------------------------
	/// Returns the pixel format of the color table.
	//----------------------------------------------------------------------------------------
	MAXON_METHOD PixelFormat GetColorTablePixelFormat() const;

	//----------------------------------------------------------------------------------------
	/// Returns the number of color entries.
	//----------------------------------------------------------------------------------------
	MAXON_METHOD Int GetColorTableSize() const;

	//----------------------------------------------------------------------------------------
	/// Sets a specific color entry.
	/// @param[in] idx								Index of the entry to set.
	/// @param[in] srcPixelData				Source color data. The color will be automatically converted into the color format provided in the Init function.
	/// @return												OK on success.
	//----------------------------------------------------------------------------------------
	MAXON_METHOD Result<void> SetIndex(Int idx, const ImageConstBuffer& srcPixelData);

	//----------------------------------------------------------------------------------------
	/// Returns a single color entry from the color table.
	/// @param[in] idx								Index of the entry to get.
	/// @param[in] dstPixelData				Destination color pointer. The color will be automatically converted into the color format provided in the dstPixelData.
	/// @return												OK on success.
	//----------------------------------------------------------------------------------------
	MAXON_METHOD Result<void> GetIndex(Int idx, const ImageMutableBuffer& dstPixelData) const;
};

// include autogenerated headerfile here
#include "gfx_image_pixelformat_indexed1.hxx"
#include "gfx_image_pixelformat_indexed2.hxx"

/// @}

} // namespace maxon

#endif // GFX_IMAGE_PIXELFORMAT_INDEXED_H__
