// MatchBuffer.h: interface for the CMatchBuffer class.
|
//
|
//////////////////////////////////////////////////////////////////////
|
|
#if !defined(AFX_MATCHBUFFER_H__86EF7EFC_838A_4414_8DA0_655D6EC5210B__INCLUDED_)
|
#define AFX_MATCHBUFFER_H__86EF7EFC_838A_4414_8DA0_655D6EC5210B__INCLUDED_
|
|
#if _MSC_VER > 1000
|
#pragma once
|
#endif // _MSC_VER > 1000
|
|
|
#include "SISBuffer.h"
|
|
typedef unsigned short ushort;
|
typedef __int64 int64;
|
|
#define MOSIS_MEMORY_ALIGN 16
|
|
template<typename T>
|
class CMemBuff// 4byte ¾ó¶óÀÎÀ» »ç¿ëÇÏÁö ¾ÊÀ» °ÍÀÌ´Ù.
|
{
|
protected:
|
T *m_pData;
|
int m_Width;
|
int m_Height;
|
int m_DataSpace;
|
public:
|
CMemBuff()
|
{
|
m_Width= 0;
|
m_Height= 0;
|
m_DataSpace= 0;
|
m_pData= NULL;
|
}
|
virtual ~CMemBuff()
|
{
|
ReleaseSpace();
|
}
|
BYTE *GetDataAddress(){return m_pData;}
|
BYTE *GetDataAddress(int x, int y){return m_pData+ x+ y*GetWidth();}
|
int GetWidth(){return m_Width;}
|
int GetHeight(){return m_Height;}
|
int GetDataSize(){return GetWidth()*GetHeight();}
|
BOOL IsValidBuffer(){return (m_pData != NULL) && (m_Width>0) && (m_Height>0);}
|
|
void ReleaseSpace()
|
{
|
if(m_pData)
|
{
|
#if defined(MOSIS_MEMORY_ALIGN)
|
_mm_free(m_pData);
|
#else
|
delete[] m_pData;
|
#endif
|
}
|
m_pData= NULL;
|
m_Width= 0;
|
m_Height= 0;
|
m_DataSpace= 0;
|
}
|
BOOL SetSize(int width, int height)
|
{
|
int space= width*height;
|
if(space < 1)
|
return FALSE;
|
|
if(m_DataSpace < space)
|
{
|
ReleaseSpace();
|
}
|
|
if(m_pData == NULL)
|
{
|
#if defined(MOSIS_MEMORY_ALIGN)
|
m_pData= (BYTE*)_mm_malloc(space*sizeof(BYTE), MOSIS_MEMORY_ALIGN);
|
#else
|
m_pData= new BYTE[space];
|
#endif
|
m_DataSpace= space;
|
}
|
|
m_Width= width;
|
m_Height= height;
|
return IsValidBuffer();
|
}
|
void SetPixel(int x, int y, T val)
|
{
|
*(m_pData+ x+ y*GetWidth())= val;
|
}
|
};
|
|
|
class CUShortBuff// 4byte ¾ó¶óÀÎÀ» »ç¿ëÇÏÁö ¾ÊÀ» °ÍÀÌ´Ù.
|
{
|
public:
|
CUShortBuff();
|
virtual ~CUShortBuff();
|
|
protected:
|
ushort *m_pData;
|
int m_Width;
|
int m_Height;
|
int m_DataSpace;
|
|
public:
|
ushort *GetDataAddress(){return m_pData;}
|
ushort *GetDataAddress(int x, int y){return m_pData+ x+ y*GetWidth();}
|
int GetWidth(){return m_Width;}
|
int GetHeight(){return m_Height;}
|
int GetDataSize(){return GetWidth()*GetHeight();}
|
BOOL IsValidBuffer(){return (m_pData != NULL) && (m_Width>0) && (m_Height>0);}
|
|
public:
|
void ReleaseSpace();
|
BOOL SetSize(int width, int height);
|
BOOL SetBuffPyramid(CSISBuffer from, CRect roi, int multi);
|
void SetPixel(int x, int y, ushort val)
|
{
|
*(m_pData+ x+ y*GetWidth())= val;
|
}
|
BOOL CopyFrom(CUShortBuff &fromBuffer, CRect rect);
|
};
|
|
class CByteBuff// 4byte ¾ó¶óÀÎÀ» »ç¿ëÇÏÁö ¾ÊÀ» °ÍÀÌ´Ù.
|
{
|
protected:
|
BYTE *m_pData;
|
int m_Width;
|
int m_Height;
|
int m_DataSpace;
|
public:
|
CByteBuff()
|
{
|
m_Width= 0;
|
m_Height= 0;
|
m_DataSpace= 0;
|
m_pData= NULL;
|
}
|
virtual ~CByteBuff()
|
{
|
ReleaseSpace();
|
}
|
BYTE *GetDataAddress(){return m_pData;}
|
BYTE *GetDataAddress(int x, int y){return m_pData+ x+ y*GetWidth();}
|
int GetWidth(){return m_Width;}
|
int GetHeight(){return m_Height;}
|
int GetDataSize(){return GetWidth()*GetHeight();}
|
BOOL IsValidBuffer(){return (m_pData != NULL) && (m_Width>0) && (m_Height>0);}
|
|
void ReleaseSpace();
|
BOOL SetSize(int width, int height);
|
BOOL SetBuffPyramid(CSISBuffer from, CRect roi, int multi);
|
void SetPixel(int x, int y, BYTE val)
|
{
|
*(m_pData+ x+ y*GetWidth())= val;
|
}
|
BOOL CopyFrom(CSISBuffer &buffer, CRect rect);
|
BOOL CopyFrom(CByteBuff &buffer, CRect rect);
|
};
|
|
#endif // !defined(AFX_MATCHBUFFER_H__86EF7EFC_838A_4414_8DA0_655D6EC5210B__INCLUDED_)
|