#pragma once

#ifndef	_IMAGESDKLIB_CTRL_
#define	_IMAGESDKLIB_CTRL_

#include "Nkfl_Interface.h"

// Library Name
#if defined (ILSDK_SAMPLE)
#ifdef _DEBUG
#define FLSTR_IMAGESDKLIB_PATH_VER	"NkImgSDKD.dll"
#else
#define FLSTR_IMAGESDKLIB_PATH_VER	"NkImgSDK.dll"
#endif
#endif

#ifdef _WINDOWS
#else
	#define		kVMMemorySizeKeyName	"ImageLibCtrl.VMSize"
	#define		kVMVMFilePath			"ImageLibCtrl.VMFilePath"
#endif

#define SHIFT_TO_MEGA 20			// for convert MByte <-> Byte

// image information structure
typedef struct NkIL_ImageInfo
{
	unsigned long		ulThumbID;			// Thumbnail ID
	unsigned long		ulWidth;			// Pixel width
	unsigned long		ulHeight;			// Pixel height
	unsigned long		ulByteDepth;		// Byte depth
	unsigned long		ulColor;			// Color info
	unsigned long		ulOrientation;		// Rotate/Flip
	double				dbResolution;		// Resolution
} NkIL_ImageInfo;

typedef struct NkIL_ImageParam
{
	unsigned long		ulThumbID;			// Thumbnail ID
	RECT				rect;				// for memory, draw
	unsigned long		ulLength;			// for memory
	void*				pData;				// for memory
	NkflProgressProc*	pFunc;				// callback routine
	void*				pProgressParam;		// callback parameter

} NkIL_ImageParam;

typedef struct NkIL_TagDataParam
{
	unsigned long		ulTagID;			
	unsigned long		ulTagType;			
	unsigned long		ulTagLength;
	unsigned long		ulTagValue;
	void*				pData;
} NkIL_TagDataParam;

typedef struct NkIL_TagStringParam
{
	unsigned long		ulLines;			// line count
	unsigned long		ulColumns;			// column count
	unsigned long		ulLength;			// string length
	unsigned long		ulLayout;			// layout length
	char*				pData;				// data buffer	
} NkIL_TagStringParam;

typedef struct NkIL_WBInfo
{
	unsigned long		ulMWB;				// WB parameter
	long				lColorTemp;			// color temperature
	NkflRGB				rgb;				// struct of rgb data
} NkIL_WBInfo;

typedef NkflRawDevelopment_PictureControl NkIL_PicCtrlParam;

class IStratoManager;
/**************************************************************************
		FileLibrary access class
**************************************************************************/
class CImageLibCtrl
{
public:

	// Static functions
	static unsigned long	OpenLibrary ();
	static unsigned long	CloseLibrary();

protected:
	static bool			LoadFileLibrary();

public:
	CImageLibCtrl();
	~CImageLibCtrl();

	unsigned long	OpenSession(void *pData, unsigned long ulSize = 0);
	unsigned long	CloseSession();
	unsigned long	GetFileInfo( unsigned long *pulFormat );
	unsigned long	SetOutputProfile( unsigned long ulRenderingIntent /*eNkflREnderingIntent*/, unsigned char *pProfilePath );
	unsigned long	GetOutputProfile( unsigned long *pulRenderingIntent /*eNkflREnderingIntent*/, unsigned char *pProfilePath );
	unsigned long	GetImageInfo( NkIL_ImageInfo *pImgInfo );
	unsigned long	SetImageInfo( NkIL_ImageInfo *pImgInfo );
	unsigned long	GetOriginalInfo( NkIL_ImageInfo *pImgInfo );
	unsigned long	GetRawDevelopmentInfo( unsigned long *pulRawDevelopment );
	unsigned long	RawDevelopment( unsigned long ulRawDevelopment, void *pData );
	unsigned long	GetRawDevelopmentParam( unsigned long ulRawDevelopment, void *pData );
	unsigned long	GetColorTempRange( unsigned long ulMWB, unsigned long *pulDefault, unsigned long *pulMinColorTemp, unsigned long *pulMaxColorTemp );
	unsigned long	GetImageData(NkIL_ImageParam* pParam);
	unsigned long	GetThumbnailCount( unsigned long *pulThumbnailCount );
	unsigned long	GetThumbnailInfo( NkIL_ImageInfo *pImgInfo );
	unsigned long	SetThumbnailInfo( NkIL_ImageInfo *pImgInfo );
	unsigned long	GetThumbnailData(NkIL_ImageParam* pParam);
	unsigned long	GetTagInfo(unsigned long* pulList, unsigned long* pulCout);
	unsigned long	GetTagData( NkIL_TagDataParam* pParam );
	unsigned long	GetTagStringInfo( unsigned long *pulLines, unsigned long *pulColumns );
	unsigned long	GetTagString(NkIL_TagStringParam* pData);

	unsigned long	GetRawQuality( unsigned long* pulRawQuality );
	unsigned long	GetParamSettings( unsigned long* pulParamSet );
	unsigned long	GetExpComp( double* pdbExpComp );
	unsigned long	GetWBInfo( NkIL_WBInfo* pStrWBParam );
	unsigned long	GetTint( long* plTint );
	unsigned long	GetNR( unsigned long* pulNR, bool* pbIsNR );
	unsigned long	GetADL( unsigned long* pulADL , bool* pbIsADL );
	unsigned long	GetColorMode( unsigned long* pulColorMode, bool* pbIsColorMode );
	unsigned long	GetSharpness( unsigned long* pulSharpness );
	unsigned long	GetToneComp( unsigned long* pulToneComp );
	unsigned long	GetSaturation( unsigned long* pulSaturation );
	unsigned long	GetHueAdj( long* plHueAdj );
	unsigned long	GetFiltEffect( unsigned long* pulFiltEffect );
	unsigned long	GetPicCtrl( NkIL_PicCtrlParam* pStrPicCtrl );
	unsigned long	SetRawQuality( unsigned long ulRawQuality );
	unsigned long	SetParamSettings( unsigned long ulParamSet );
	unsigned long	SetExpComp( double dbExpComp );
	unsigned long	SetWBInfo( NkIL_WBInfo StrWBParam );
	unsigned long	SetTint( long lTint );
	unsigned long	SetNR( unsigned long ulNR );
	unsigned long	SetADL( unsigned long ulADL );
	unsigned long	SetColorMode( unsigned long ulColorMode );
	unsigned long	SetSharpness( unsigned long ulSharpness );
	unsigned long	SetToneComp( unsigned long ulToneComp );
	unsigned long	SetSaturation( unsigned long ulSaturation );
	unsigned long	SetHueAdj( long lHueAdj );
	unsigned long	SetFiltEffect( unsigned long ulFiltEffect );
	unsigned long	SetPicCtrl( NkIL_PicCtrlParam StrPicCtrl );
	
	bool			IsOpen() { return (m_ulSessionID == 0)? FALSE : TRUE;};
	bool			IsApplyPictCtrl() { return m_bApplyPictCtrl; };

protected:

	unsigned long	m_ulSessionID;					// SessionID
	bool			m_bApplyPictCtrl;				// flag of apply picturecontrol
};

#endif // _IMAGESDKLIB_CTRL_
