Rectangle Functions
来源:互联网 发布:riot.js 编辑:程序博客网 时间:2024/06/06 11:04
前言
在GDI绘图刷新无效区域时, 如果进行粗略的矩形计算, 要用到矩形操作的API.
为了减小图形的闪烁,可以一小块一小块的调用InvalidateRect.
验证代码
void fnTest() { /** <<Rectangle Functions>> RECT操作API共11个 SetRectEmpty ///< 设置RECT为空 SetRect ///< 设置RECT值 CopyRect ///< RECT之间的拷贝 EqualRect ///< 矩形是否相等 IsRectEmpty ///< 矩形是否为空 OffsetRect ///< 将矩形整体移动(x,y)的偏移 PtInRect ///< 判断点pt是否在矩形内 InflateRect ///< 增加或减小矩形的宽度和高度, 左右均变化dx, 上下均变化dy IntersectRect ///< 求2个矩形的交集, 如果没有交集, 返回空RECT /// 矩形减法, 这个用起来有限制, 被减去的矩形2必须完全遮挡住矩形1的一边(左面,右面,上面 or 下面) /// 而且必须有一个坐标必须和原坐标相同 /// 这API真挫, 可以自己封装一个SubtractRectEx, 先求交集, 然后再调用这个API SubtractRect ///< 矩形减法 UnionRect ///< 求包含2个矩形的最小矩形 */ BOOL bRc = FALSE; RECT rtSrc; RECT rtSrc1; RECT rtDst; POINT pt; SetRectEmpty(&rtDst); SetRect(&rtSrc, 100, 101, 200, 201); bRc = CopyRect(&rtDst, &rtSrc); assert(bRc); bRc = EqualRect(&rtDst, &rtSrc); assert(bRc); SetRectEmpty(&rtDst); bRc = EqualRect(&rtDst, &rtSrc); assert(!bRc); SetRectEmpty(&rtDst); bRc = IsRectEmpty(&rtDst); assert(bRc); bRc = IsRectEmpty(&rtSrc); assert(!bRc); CopyRect(&rtDst, &rtSrc); OffsetRect(&rtSrc, 10, 10); pt.x = 100; pt.y = 100; bRc = PtInRect(&rtSrc, pt); assert(!bRc); bRc = SetRect(&rtSrc, 100, 101, 200, 201); assert(bRc); bRc = InflateRect(&rtSrc, -1, -1); assert(bRc); SetRect(&rtSrc, 100, 100, 200, 200); SetRect(&rtSrc1, 101, 101, 201, 201); bRc = IntersectRect(&rtDst, &rtSrc, &rtSrc1); if (!bRc) { OutputDebugStringA("没有交集"); } /* The function only subtracts the rectangle specified by lprcSrc2 from the rectangle specified by lprcSrc1 when the rectangles intersect completely in either the x- or y-direction. For example, if *lprcSrc1 has the coordinates (10,10,100,100) and *lprcSrc2 has the coordinates (50,50,150,150), the function sets the coordinates of the rectangle pointed to by lprcDst to (10,10,100,100). If *lprcSrc1 has the coordinates (10,10,100,100) and *lprcSrc2 has the coordinates (50,10,150,150), however, the function sets the coordinates of the rectangle pointed to by lprcDst to (10,10,50,100). */ SetRect(&rtSrc, 10, 10, 100, 100); SetRect(&rtSrc1, 50, 50, 150, 150); bRc = SubtractRect(&rtDst, &rtSrc, &rtSrc1); SetRect(&rtSrc, 10, 10, 100, 100); SetRect(&rtSrc1, 50, 10, 150, 150); bRc = SubtractRect(&rtDst, &rtSrc, &rtSrc1); SetRect(&rtSrc, 10, 10, 100, 100); SetRect(&rtSrc1, 10, 20, 150, 150); SetRectEmpty(&rtDst); bRc = SubtractRect(&rtDst, &rtSrc, &rtSrc1); SetRect(&rtSrc, 10, 10, 50, 50); SetRect(&rtSrc1, 52, 52, 100, 100); SetRectEmpty(&rtDst); bRc = UnionRect(&rtDst, &rtSrc, &rtSrc1);}
0 0
- Rectangle Functions
- functions
- functions
- Functions
- Functions
- Functions
- Functions
- Functions
- Functions
- Functions
- Rectangle
- Rectangle
- Rectangle
- rectangle
- Rectangle
- Rectangle
- rectangle
- Rectangle
- shell脚本常用命令简单总结
- 配置Openfire
- H.264视频在android手机端的解码与播放
- BestCoder Round #72 (div.1) Clarke and MST
- xcode插件XAlign
- Rectangle Functions
- 新的博客启用了
- 解决OS X 10.11(OS X EL Capitan) 升级 cocoapods带来的问题(最新版)
- 乘法算式.cpp
- python基础学习九:类基础
- 自定义View入门
- ecshop安装报错
- 移动硬盘中安装Windows10
- IOCP