// SingleImage.h: interface for the CSingleImage class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SINGLEIMAGE_H__FAFB81DC_873A_11D3_8A0E_005004CEACBF__INCLUDED_)
#define AFX_SINGLEIMAGE_H__FAFB81DC_873A_11D3_8A0E_005004CEACBF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <gl/gl.h>
#include <gl/glu.h>
#include "structure.h"
#include "ViewPoint.h"
#include "TextureImage.h"

const int R = 0, G = 1, B = 2;
const int RGB = 3;
typedef CTypedPtrArray < CViewPoint> CViewPointList;
typedef CTypedPtrArray < CTextureImage > CTextureImageList;
class CSingleImage  
{
private:
	int m_iWidth,m_iHeight;
	unsigned char *m_pbSingleImage;
	GLuint m_guiTexName;
	CString m_ImageFileName;
	
public:
	int GetIndex(int pointid);
	BOOL GetImageValue(unsigned char *rgb,double x,double y);
	BOOL GetRealImageValue(int x,int y,unsigned char *rgb);
	void GenerateImageTexture(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4,int width, int height,const char * imagefilename);
	void StoreTextureImage(const char *imagefile,unsigned char *ptextureimageptr,int width,int height);

	double m_Vx[3];
	double m_Vy[3];
	double m_Vz[3];
	double a;
	double b;
	double A;
	double m_lScale[3];
	double m_l[3];
	double HMatrix[3][3];
	double HStandardMatrix[3][3];
	double x0,y0;
    
	int m_maxid;
	CViewPointList m_ViewPointListptr;
	CTextureImageList m_TextureImageListptr;

	CSingleImage(void ) { m_pbSingleImage = NULL ;}
	CSingleImage(const char* imagefile);
	virtual ~CSingleImage();
	GLuint GetTexName(void) const {return m_guiTexName;}

	int GetWidth( void )		const { return m_iWidth; }
	int GetHeight( void )		const { return m_iHeight; }
	CString GetImageFileName(void) const {return m_ImageFileName;}
	unsigned char *GetSingleImageptr(void) { return m_pbSingleImage ; }

	void Load( const char * imagefile );
	void Store( const char * imagefile );
	void GenTexture( void );

};

#endif // !defined(AFX_SINGLEIMAGE_H__FAFB81DC_873A_11D3_8A0E_005004CEACBF__INCLUDED_)
