LWQ
2025-07-14 aef42eef51d1b86ac7217a88ce17c5156c30fe6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// 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_)