rtc.avd_SDK-C++  3.2.0
annotationbasedefines.h
浏览该文件的文档.
1 #ifndef RT_AnnotationBaseDefines_H_
2 #define RT_AnnotationBaseDefines_H_
3 
4 
5 #include "list"
6 
7 
8 namespace rtcimp {
9 
10  /* 点对象信息结构.
11  */
12  typedef struct tagPoint {
13  int x;
14  int y;
15  tagPoint() :x(0), y(0) {}
16  tagPoint(int x, int y) :x(x), y(y) {}
17  }Point;
18 
19  typedef std::list<Point> PointArray;
20 
24  typedef struct tagRect {
25  int left;
26  int top;
27  int right;
28  int bottom;
29  tagRect() :left(0), top(0), right(0), bottom(0) {}
30  tagRect(int left, int top, int right, int bottom) :left(left), top(top), right(right), bottom(bottom) {}
31  bool isRectEmpty() const { return (left == right || top == bottom); }
32  int width() const { return right - left; }
33  int height() const { return bottom - top; }
34  bool pointIn(const Point& p) const { return pointIn(p.x, p.y); }
35  bool pointIn(int x, int y) const { return x >= left && right >= x && y >= top && bottom >= y; }
36  void moveY(int y) { int h = height(); top = y; bottom = top + h; }
37  void moveX(int x) { int w = width(); left = x; right = left + w; }
38  void moveXY(int x, int y) { moveX(x); moveY(y); }
39  bool operator ==(const tagRect& other) const { return left == other.left && right == other.right && top == other.top && bottom == other.bottom; }
40  bool operator !=(const tagRect& other) const { return !(*this == other); }
41  }Rect;
42  typedef struct tagColor {
43  unsigned long color;
44  tagColor() : tagColor(0, 0, 0, 0) {}
45  tagColor(unsigned long val) : color(val) {}
46  tagColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
47  :color(((r | ((unsigned long)g << 8)) | (((unsigned long)b) << 16)) | (((unsigned long)a) << 24)) {}
48  unsigned char r() const { return color & 0xFF; }
49  unsigned char g() const { return (color >> 8) & 0xFF; }
50  unsigned char b() const { return (color >> 16) & 0xFF; }
51  unsigned char a() const { return (color >> 24) & 0xFF; }
52  unsigned long rgb() const { return color & 0xFFFFFF; }
53  unsigned long argb() const { return ((b() | ((unsigned long)g() << 8)) | (((unsigned long)r()) << 16)) | (((unsigned long)a()) << 24); }
54  void setR(unsigned char r) { color = (color & 0xFFFFFF00) | ((unsigned long)r & 0xFF); }
55  void setG(unsigned char g) { color = (color & 0xFFFF00FF) | (((unsigned long)g & 0xFF) << 8); }
56  void setB(unsigned char b) { color = (color & 0xFF00FFFF) | (((unsigned long)b & 0xFF) << 16); }
57  void setA(unsigned char a) { color = (color & 0x00FFFFFF) | (((unsigned long)a & 0xFF) << 24); }
58  void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { setA(a); setR(r); setG(g); setB(b); }
59  }Color;
60 
61 }
62 #endif //RT_AnnotationBaseDefines_H_
tagColor()
Definition: annotationbasedefines.h:44
int top
Definition: annotationbasedefines.h:26
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: annotationbasedefines.h:58
tagPoint(int x, int y)
Definition: annotationbasedefines.h:16
int bottom
Definition: annotationbasedefines.h:28
int width() const
Definition: annotationbasedefines.h:32
unsigned long rgb() const
Definition: annotationbasedefines.h:52
void setA(unsigned char a)
Definition: annotationbasedefines.h:57
void setB(unsigned char b)
Definition: annotationbasedefines.h:56
unsigned char a() const
Definition: annotationbasedefines.h:51
Definition: annotationbasedefines.h:12
bool pointIn(int x, int y) const
Definition: annotationbasedefines.h:35
int x
Definition: annotationbasedefines.h:13
区域对象信息结构.
Definition: annotationbasedefines.h:24
int y
Definition: annotationbasedefines.h:14
struct rtcimp::tagColor Color
tagColor(unsigned long val)
Definition: annotationbasedefines.h:45
std::list< Point > PointArray
Definition: annotationbasedefines.h:19
Definition: annotationbasedefines.h:42
void moveY(int y)
Definition: annotationbasedefines.h:36
int right
Definition: annotationbasedefines.h:27
tagColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: annotationbasedefines.h:46
tagRect()
Definition: annotationbasedefines.h:29
bool pointIn(const Point &p) const
Definition: annotationbasedefines.h:34
tagPoint()
Definition: annotationbasedefines.h:15
bool isRectEmpty() const
Definition: annotationbasedefines.h:31
Definition: annotationbasedefines.h:8
struct rtcimp::tagRect Rect
区域对象信息结构.
unsigned long color
Definition: annotationbasedefines.h:43
unsigned char g() const
Definition: annotationbasedefines.h:49
void moveX(int x)
Definition: annotationbasedefines.h:37
unsigned char b() const
Definition: annotationbasedefines.h:50
void moveXY(int x, int y)
Definition: annotationbasedefines.h:38
unsigned long argb() const
Definition: annotationbasedefines.h:53
bool operator !=(const tagRect &other) const
Definition: annotationbasedefines.h:40
struct rtcimp::tagPoint Point
void setR(unsigned char r)
Definition: annotationbasedefines.h:54
tagRect(int left, int top, int right, int bottom)
Definition: annotationbasedefines.h:30
unsigned char r() const
Definition: annotationbasedefines.h:48
int left
Definition: annotationbasedefines.h:25
int height() const
Definition: annotationbasedefines.h:33
void setG(unsigned char g)
Definition: annotationbasedefines.h:55
bool operator==(const tagRect &other) const
Definition: annotationbasedefines.h:39