forked from Breeze-del/C-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StillObj.cpp
66 lines (52 loc) · 1.71 KB
/
StillObj.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
// StillObj.cpp: implementation of the CStillObj class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "StillObj.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CStillObj::CStillObj()
{
}
CStillObj::~CStillObj()
{
}
void CStillObj::Draw(IplImage *bg, double down, double up, double l, int tx, int ty)
{
double m = (double)l * m_img->height;
double light;
for (int i = 0; i < m_img->height; i++) {
for (int j = 0; j < m_img->width; j++) {
if (i + m_Position.y + ty >= bg->height ||
j + m_Position.x + tx >= bg->width ||
i + m_Position.y + ty< 0 ||
j + m_Position.x + tx< 0
)continue; //超过边界的不打印.
if (CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 0) <= 10 &&
CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 1) >= 135 &&
CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 1) <= 155 &&
CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 2) <= 10
)continue;//纯色控制
if (i > m_img->height - m)
light = down;
else
light = up;
CV_IMAGE_ELEM(bg, uchar, i + m_Position.y + ty, (j + m_Position.x + tx) * 3 + 0)
= (unsigned char)(CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 0) * light);
CV_IMAGE_ELEM(bg, uchar, i + m_Position.y + ty, (j + m_Position.x + tx) * 3 + 1)
= (unsigned char)(CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 1) * light);
CV_IMAGE_ELEM(bg, uchar, i + m_Position.y + ty, (j + m_Position.x + tx) * 3 + 2)
= (unsigned char)(CV_IMAGE_ELEM(m_img, uchar, i, j * 3 + 2) * light);
}
}
}
void CStillObj::SetPos(int x, int y)
{
m_Position.x = x;
m_Position.y = y;
}
void CStillObj::Timething()
{
m_isCd = false;
}