//---------------------------------------------------------------------------
#ifndef ImgCopperExUnitH
#define ImgCopperExUnitH
#include "NotificationExUnit.h"

#define SAFE_DELETE(p) { if(p) { delete (p);     (p)=NULL; } }
#define MUSIC_COVER_DIR    L"MusicCover\\"
#define MUSIC_COVER_FILE   L"MusicCover"
#define MUSIC_COVER_COPPER L"MusicCoverCopper.jpg"
//---------------------------------------------------------------------------
bool  GetPicType(String &name, TMemoryStream *tmpMemoryStream, bool bBac);
//---------------------------------------------------------------------------
typedef struct UIEdgeInsets {

		int left, right, top, bottom;

		UIEdgeInsets(int ileft, int iright, int itop, int ibottom) {

			left   = ileft;
			right  = iright;
			top    = itop;
			bottom = ibottom;
		}

		UIEdgeInsets(){
			left   = -1;
			right  = -1;
			top    = -1;
			bottom = -1;
		}

} UIEdgeInsets;

typedef struct tagUIEdgeInsetsBMP{

		TBitmap   *pImgLeftT,*pImgLeftB,*pImgRightT,*pImgRightB;

		TBitmap   *pImgCenterL, *pImgCenterR, *pImgCenterT, *pImgCenterB, *pImgCenter;

		TBitmap   *pImgBMPSrc;

		UIEdgeInsets insetsDest;
		int 	     iTag;
		String       strResourceName;

		tagUIEdgeInsetsBMP(int tag, String resourceName) {

			iTag = tag;
			strResourceName = resourceName;
			pImgLeftT   = pImgLeftB   = pImgRightT  = pImgRightB  = NULL;
			pImgCenterL = pImgCenterR = pImgCenterT = pImgCenterB = pImgCenter = NULL;
			pImgBMPSrc  = NULL;
		}

		~tagUIEdgeInsetsBMP() {

			SAFE_DELETE(pImgLeftT)
			SAFE_DELETE(pImgLeftB)
			SAFE_DELETE(pImgRightT)
			SAFE_DELETE(pImgRightB)

			SAFE_DELETE(pImgCenterL)
			SAFE_DELETE(pImgCenterR)
			SAFE_DELETE(pImgCenterT)
			SAFE_DELETE(pImgCenterB)
			SAFE_DELETE(pImgCenter)

			SAFE_DELETE(pImgBMPSrc)
		}

		void SetTransparent(System::Uitypes::TColor TransparentColor) {

			pImgLeftT->Transparent        = true;
			pImgLeftT->TransparentColor   = TransparentColor;
			pImgLeftB->Transparent        = true;
			pImgLeftB->TransparentColor   = TransparentColor;
			pImgRightT->Transparent       = true;
			pImgRightT->TransparentColor  = TransparentColor;
			pImgRightB->Transparent       = true;
			pImgRightB->TransparentColor  = TransparentColor;
			pImgCenterL->Transparent      = true;
			pImgCenterL->TransparentColor = TransparentColor;
			pImgCenterR->Transparent      = true;
			pImgCenterR->TransparentColor = TransparentColor;
			pImgCenterT->Transparent      = true;
			pImgCenterT->TransparentColor = TransparentColor;
			pImgCenterB->Transparent      = true;
			pImgCenterB->TransparentColor = TransparentColor;
			pImgCenter->Transparent       = true;
			pImgCenter->TransparentColor  = TransparentColor;
		}

}BMPEDGE;
typedef vector<BMPEDGE*> 	VCBMPEDGE;
TBitmap* resizableImage(TBitmap *imgDest,  TRect rectDest,
						int tagSrc, String resourceNameSrc,
						UIEdgeInsets insetsSrc,
						System::Uitypes::TColor TransparentColor=clWhite);
//---------------------------------------------------------------------------
class TThreadMusciCover : public TThread
{
private:
	TForm *m_pForm;
protected:
	void __fastcall Execute();
public:
	__fastcall TThreadMusciCover(bool CreateSuspended, TForm *Form);
};
extern TThreadMusciCover *g_pTThreadMusciCover;
//---------------------------------------------------------------------------
class TThreadHttpPostUsrIcon : public TThread
{
private:
	TWinControl *m_pWnCtrl;
	String m_strPath;

protected:
	void __fastcall Execute();

public:
	String m_strFileName;
	__fastcall TThreadHttpPostUsrIcon(bool CreateSuspended, TWinControl *pWnCtrl, String strPath);
};
extern TThreadHttpPostUsrIcon *g_pTThreadHttpPostUsrIcon;
//---------------------------------------------------------------------------
#endif
