/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014 Raytrix GmbH. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "RxImageTypes.h"

#ifndef RX_STATIC
    #ifdef RXINTEROP28_EXPORTS
		#define RXINTEROP28_API __declspec(dllexport)
    #else
		#define RXINTEROP28_API __declspec(dllimport)
    #endif
#else
	#define RXINTEROP28_API
#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// namespace: Rx.Interop.Runtime28
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Rx
{
	namespace Interop
	{
		namespace Runtime28
		{
/**
        \addtogroup RxCore_Image
**/
/// @{

			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			/// <summary>
			/// 	Interface supported by Raytrix images.
			/// </summary>
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			class RXINTEROP28_API IImage
			{
			public:

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Create an image of given type and size and reserve the appropriate amount of memory. We can use as input types enums as
				/// 	they stay compatible between module versions even if the enum declarations have different numbers of entries.
				/// </summary>
				///
				/// <param name="iWidth">	 	Zero-based index of the width. </param>
				/// <param name="iHeight">   	Zero-based index of the height. </param>
				/// <param name="ePixelType">	Type of the pixel. </param>
				/// <param name="eDataType"> 	Type of the data. </param>
				///
				/// <returns>	True if it succeeds, false if it fails. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual bool Create(int iWidth, int iHeight, Interop::Runtime28::EPixelType::ID ePixelType, Interop::Runtime28::EDataType::ID eDataType) = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Create an image of given type and size and copy the data from the given pointer.
				/// </summary>
				///
				/// <param name="iWidth">	 	Zero-based index of the width. </param>
				/// <param name="iHeight">   	Zero-based index of the height. </param>
				/// <param name="ePixelType">	Type of the pixel. </param>
				/// <param name="eDataType"> 	Type of the data. </param>
				/// <param name="pData">	 	The data. </param>
				///
				/// <returns>	True if it succeeds, false if it fails. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual bool Create(int iWidth, int iHeight, Interop::Runtime28::EPixelType::ID ePixelType,     Interop::Runtime28::EDataType::ID eDataType, const void* pData) = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Create image from given image.
				/// </summary>
				///
				/// <param name="pImage">	The image. </param>
				///
				/// <returns>	True if it succeeds, false if it fails. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual bool Create(const IImage* pImage) = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Destroy image.
				/// </summary>
				///
				/// <returns>	True if it succeeds, false if it fails. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual bool Destroy() = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Test whether this image exists.
				/// </summary>
				///
				/// <returns>	True if valid, false if not. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual bool IsValid() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the bytes per pixel.
				/// </summary>
				///
				/// <returns>	The bytes per pixel. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual int GetBytesPerPixel() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the pixel count.
				/// </summary>
				///
				/// <returns>	The pixel count. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual unsigned GetPixelCount() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the byte count.
				/// </summary>
				///
				/// <returns>	The byte count. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual unsigned GetByteCount() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the size of this image.
				/// </summary>
				///
				/// <param name="iWidth"> 	[out] The width. </param>
				/// <param name="iHeight">	[out] The height. </param>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual void GetSize(int& iWidth, int& iHeight) const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the type of this image.
				/// </summary>
				///
				/// <param name="ePixelType">	[out] Type of the pixel. </param>
				/// <param name="eDataType"> 	[out] Type of the data. </param>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual void GetType(Interop::Runtime28::EPixelType::ID& ePixelType, Interop::Runtime28::EDataType::ID& eDataType) const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the data pointer.
				/// </summary>
				///
				/// <returns>	Null if it fails, else the data pointer. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual void* GetDataPtr() = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the data pointer.
				/// </summary>
				///
				/// <returns>	Null if it fails, else the data pointer. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual const void* GetDataPtr() const = 0;
			};

			/// @}
		}
	}
}

#pragma make_public(Rx::Interop::Runtime28::IImage)
