forked from baojie/Hough
/
ImageRegion.cpp
executable file
·74 lines (59 loc) · 1.44 KB
/
ImageRegion.cpp
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
// ImageRegion.cpp: implementation of the CImageRegion class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ImageRegion.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CImageRegion::CImageRegion()
{
}
CImageRegion::~CImageRegion()
{
}
BOOL CImageRegion::IsEmpty()
{
return GetSafeHandle()==NULL;
}
int CImageRegion::SetRegion(CRgn rgn)
{
DeleteObject();
return CopyRgn(&rgn);
}
BOOL CImageRegion::DrawStroke(CDC* pDC)
{
pDC->MoveTo(m_pointArray[0]);
for (int i=1; i < m_pointArray.GetSize(); i++)
{
pDC->LineTo(m_pointArray[i]);
}
return TRUE;
}
BOOL CImageRegion::CreateRegion(CRgn *pRgn,int fnFillMode)
{
// AfxMessageBox("CStroke::CreateRegion");
CPoint *points=new CPoint[m_pointArray.GetSize()];
for (int i=0; i < m_pointArray.GetSize(); i++)
points[i]=m_pointArray[i];
BOOL bSuccess=pRgn->CreatePolygonRgn(points,
m_pointArray.GetSize(),
fnFillMode);
delete points;
return bSuccess;
}
BOOL CImageRegion::IsStrobeEmpty()
{
return m_pointArray.GetSize()==0;
}
void CImageRegion::Clear()
{
if(!IsStrobeEmpty())
m_pointArray.RemoveAll();
return;
}