-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZoomInfo_Multi.cpp
More file actions
115 lines (84 loc) · 2.32 KB
/
ZoomInfo_Multi.cpp
File metadata and controls
115 lines (84 loc) · 2.32 KB
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
// ZoomInfo_Multi.cpp: implementation of the CZoomInfo_Multi class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "NewProject01View.h"
#include "ZoomInfo_Multi.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CZoomInfo_Multi::CZoomInfo_Multi()
{
}
CZoomInfo_Multi::~CZoomInfo_Multi()
{
}
int CZoomInfo_Multi::GetTotalImageNum()
{
return m_nTotalImageNum;
}
CRect CZoomInfo_Multi::GetSourceRect(int nNum)
{
CRect rect = CZoomInfo::GetSourceRect();
rect.right += rect.left;
int nLeft = nNum*m_szImageSize.cx/m_nTotalImageNum;
int nRight = nLeft + m_szImageSize.cx/m_nTotalImageNum-1;
if( nRight < rect.left || nLeft > rect.right ) return CRect(0, 0, 0, 0);
// else if( nLeft >= rect.left && nRight <= rect.right ){
// rect.left = rect.left;
// rect.right = nRight-nLeft;
// return rect;
else {
if( rect.left <= nLeft ) rect.left = nLeft;
if( rect.right >= nRight ) rect.right = nRight;
rect.right = (rect.right-rect.left+1);
rect.left -= nNum*m_szImageSize.cx/m_nTotalImageNum;
return rect;
}
}
CRect CZoomInfo_Multi::GetDestRect(int nNum)
{
CRect rect = GetSourceRect(nNum);
rect.left += m_szImageSize.cx/m_nTotalImageNum*nNum;
rect.right += rect.left-1;
rect.bottom += rect.top-1;
rect = GetBound(rect);
rect.right -= (rect.left-1);
rect.bottom -= (rect.top-1);
return rect;
}
CZoomInfo_Multi::CZoomInfo_Multi(CSize szSize, CRect rcRect, int nImageNum, bool bRightRect)
:CZoomInfo(szSize, rcRect, bRightRect)
{
m_nTotalImageNum = nImageNum;
}
int CZoomInfo_Multi::GetImageNum(CPoint ptPoint)
{
CRect rect;
for(int i=0; i<m_nTotalImageNum; i++){
rect = GetImageRect(i);
if( ptPoint.x >= rect.left && ptPoint.x <= rect.right ) return i;
}
return 0;
}
CPoint CZoomInfo_Multi::ToSubImageCoord(CPoint ptPoint)
{
int num = GetImageNum(ptPoint);
ptPoint.x -= GetImageRect(num).left;
return ptPoint;
}
CRect CZoomInfo_Multi::GetImageRect(int nNum)
{
CRect ret;
int nWidth = m_szImageSize.cx/m_nTotalImageNum;
ret.left = nWidth * nNum;
ret.right = nWidth*(nNum+1)-1;
ret.top = 0;
ret.bottom = m_szImageSize.cy;
return ret;
}