DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  4737 随笔 :: 2 文章 :: 542 评论 :: 1615万 阅读
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

1、画笔

有两种形式创建画笔

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

二是通过创建画笔来调用

 HPEN CreatePen(
  int
 fnPenStyle,    // pen style
  int nWidth,        // pen width
  COLORREF crColor   // 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 函数的作用是刷新用户区,(使区域无效)
posted on   DoubleLi  阅读(600)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示