#pragma once

#include <wininet.h>

#include "ximage.h"
/*
	//CString raw = _T("./1.raw");
	//CString dst = _T("./1.png");

	//CImageUtility IU;
	//IU.MakeImage(raw, dst, 2520, 3032); default 14 bit
	//IU.MakeImage(raw, dst, 3072, 3072, 14);
	//IU.MakeImage(raw, dst, 2520, 3032, 16);

	//IU.ResizeImage (dst, 480, 480);

	//FTP_INFO *FI = new FTP_INFO;
	//FI->ConnectAddress = _T("192.168.51.5");
	//FI->ConnectPort = 21;
	//FI->Id = _T("-----");
	//FI->Pw = _T("-----");
	//FI->DirPath = _T("/소프트웨어연구소tmp");
	//FI->UploadFile = dst;

	//IU.FileUpload ( FI );
*/

#define SAFE_DELETE(x) if (ftpinfo) delete ftpinfo; ftpinfo = NULL;

DWORD WINAPI WorkerFunction( LPVOID ); 

typedef struct _FTP_INFO
{
	CString ConnectAddress;
	INTERNET_PORT ConnectPort;
	CString DirPath;
	CString Id;
	CString Pw;
	CString UploadFile;
	BOOL CheckConnect;

	_FTP_INFO (BOOL bCheckConnect = FALSE)
	{
		CheckConnect = bCheckConnect;
	};

}FTP_INFO;
 
typedef struct
{
    CHAR* pHost;
    CHAR* pUser;
    CHAR* pPass;
} PARM;

class CImageUtility
{
public:
	CImageUtility(void);
	virtual ~CImageUtility(void);

private:	
	BOOL FileRead (CString FilePath, uint32_t Width, uint32_t Height, void *mem, uint32_t TypeSize);	

	// ThreadFnc
	CWinThread *pFtpUploadThread;
	CWinThread *pFtpUploadThread_ing;

	static UINT FileRead_Thread ( LPVOID pParam );

protected:
public:

	BOOL MakeImage (CString strRawFilePath, CString strOutFilePath, uint32_t Width, uint32_t Height, UINT Type = 14);
	void ResizeImage (CString strFilePath, uint32_t Width, uint32_t Height);
	void FileUpload (FTP_INFO *ftpinfo);
};