vc绘图工具、颜色和绘图函数

摘要:
1.创建笔刷有两种方法。一种是直接通过GetStockObject()函数调用它。另一种方法是通过创建笔刷来调用HPENCreatePen(intfnPenStyle,//penstyleintnWidth,//penwidthCOLOREFcrColor//pencolor);创建画笔后,必须调用SelectObject函数将对象选择到设备环境中;删除笔刷可以通过DeleteObject函数实现;2.笔刷创建

1、画笔

有两种形式创建画笔

一是直接通过GetStockObject()函数来调用

二是通过创建画笔来调用

HPEN CreatePen(
int
fnPenStyle,// pen style
intnWidth,// pen width
COLORREFcrColor // pen color
);

创建画笔后必须调用SelectObject函数来将起选入设备环境;

删除画笔可通过DeleteObject 函数来实现;

2、画刷

创建画刷

一是通过GetStockObject函数来调用

二是通过调用CreateSolidBrush 和CreateHatchBrush来创建画刷

HBRUSH CreateSolidBrush(   COLORREF crColor   // brush color value );
HBRUSH CreateHatchBrush(   int fnStyle,      // hatch style   COLORREF clrref   // color value ); 
3、颜色
通过RGB函数来实现;
4、常用的绘图函数
设置画笔当前的位置函数MoveToEx
BOOL MoveToEx(   HDC hdc,          // handle to device context   int X,            // x-coordinate of new current position   int Y,            // y-coordinate of new current position   LPPOINT lpPoint   // pointer to old current position ); 
从当前位置向指定坐标点画直线的函数LineTo
BOOL LineTo(   HDC hdc,    // device context handle   int nXEnd,  // x-coordinate of line's ending point   int nYEnd   // y-coordinate of line's ending point );
 从当前位置开始,依次用线段连接lpPoints中指定各点的函数Polyline
BOOL Polyline(   HDC hdc,            // handle to device context   CONST POINT *lppt,  // pointer to array containing endpoints   int cPoints         // number of points in the array ); 
椭圆弧线Arc
BOOL Arc(   HDC hdc,         // handle to device context   int nLeftRect,   // x-coord of bounding rectangle's upper-left corner   int nTopRect,    // y-coord of bounding rectangle's upper-left corner   int nRightRect,  // x-coord of bounding rectangle's lower-right corner   int nBottomRect, // y-coord of bounding rectangle's lower-right corner   int nXStartArc,  // first radial ending point   int nYStartArc,  // first radial ending point   int nXEndArc,    // second radial ending point   int nYEndArc     // second radial ending point ); 
画一个饼图并用当前的画刷进行填充Pie
BOOL Pie(   HDC hdc,         // handle to device context   int nLeftRect,   // x-coord of bounding rectangle's upper-left corner   int nTopRect,    // y-coord of bounding rectangle's upper-left corner   int nRightRect,  // x-coord of bounding rectangle's lower-right corner   int nBottomRect, // y-coord of bounding rectangle's lower-right corner   int nXRadial1,   // x-coord of first radial's endpoint   int nYRadial1,   // y-coord of first radial's endpoint   int nXRadial2,   // x-coord of second radial's endpoint   int nYRadial2    // y-coord of second radial's endpoint );  
画一个矩形,并填充Rectangle
BOOL Rectangle(   HDC hdc,         // handle to device context   int nLeftRect,   // x-coord of bounding rectangle's upper-left corner   int nTopRect,    // y-coord of bounding rectangle's upper-left corner   int nRightRect,  // x-coord of bounding rectangle's lower-right corner   int nBottomRect  // y-coord of bounding rectangle's lower-right corner ); 
画一个椭圆并填充Ellipse
BOOL Ellipse(   HDC hdc,        // handle to device context   int nLeftRect,  // x-coord of bounding rectangle's upper-left corner   int nTopRect,   // y-coord of bounding rectangle's upper-left corner   int nRightRect, // x-coord of bounding rectangle's lower-right corner   int nBottomRect // y-coord of bounding rectangle's lower-right corner ); 
画一个多边形,并进行填充Polygon
BOOL Polygon(   HDC hdc,                // handle to device context   CONST POINT *lpPoints,  // pointer to polygon's vertices   int nCount              // count of polygon's vertices ); 
InvalidateRect 函数的作用是刷新用户区,(使区域无效)

免责声明:文章转载自《vc绘图工具、颜色和绘图函数》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇cdn技术浅谈 大风起pureMVC简单示例及其原理讲解四(Controller层)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

C++解析(28):异常处理

0.目录 1.C语言异常处理 2.C++中的异常处理 3.小结 1.C语言异常处理 异常的概念: 程序在运行过程中可能产生异常 异常(Exception)与 Bug 的区别 异常是程序运行时可预料的执行分支 Bug 是程序的错误,是不被预期的运行方式 异常(Exception)与 Bug 的对比: 异常 运行时产生除0的情况 需要打...

opencv 绘制半透明图形 (

opencv 绘制半透明图形   转载▼ 标   初学OpenCV,想绘制半透明矩形,却发现没有GDI+那么简单,在网上搜寻了一番任未得其解,偶然翻到一个对两张图片进行像素值加权叠加的函数cvAddWeighted,于是参照例程加以改造写了一个绘制半透明矩形的封装方法: void DrawTransRec(IplImage* img,in...

(转)Android之RemoteViews

RemoteViews中的setxxx方法 比如setCharSequence(int viewId, String methodName, CharSequence value); views.setString(R.id.textview01, "setText", battery + "%"); 其中views是RomoteViews的实例, 第一个...

c++模板特例化 函数模板(非法使用显式模板参数 )

这里是其中一个场景, 想了解其他的请绕行。 class 模板特例化: template<typename T, int v1> class A { public: A(T value) { a = value * v1; } T a = 0; }; template<typename T> c...

foreach 循环遍历 以及函数的应用

foreach( 对集合每个元素的引用 in 集合 ){} 举例: int[] a = new int[5]{1,2,3,4,5};foreach( int b in a ){ //b就是a中的每个元素} 注意:1.foreach只能对集合进行遍历。2.foreach在操作集合的时候,只能读不能改; 3.foreach操作Dictionary<T,T...

哈希表(hash)

散列表(Hash table,也叫哈希表),是根据键(Key)而直接访问在内存储存位置的数据结构。也就是说,它通过计算一个关于键值的函数,将所需查询的数据映射到表中一个位置来访问记录,这加快了查找速度。这个映射函数称做散列函数,存放记录的数组称做散列表。 (来自维基百科) 其中前边说到的离散化也是一种特殊的哈希方式,只不过离散化注重保序性,因此使用二分查找...