Win32 Windows编程 十
2020-12-13 04:51
标签:win32 图形 mfc sdk c++ 一 Windows绘图 1 图形绘制 1.1 图形绘制的方式 获取到绘图的句柄,设备描述符(DC),使用相应的绘图API,在设备上绘制图形 1.2 颜色 RGB,每种颜色8位,共24位颜色 32位颜色:颜色数量24为颜色,多出的8位表示灰度。 16位:颜色数量是2的16次方。 Win32下,颜色的定义使用 COLORREF。RGB的宏定义颜色 COLORREF nColor = RGB( 0, 0, 0 ); 黑色 COLORREF nColor = RGB( 255, 255, 255 ); 白色 COLORREF nColor = RGB( 255, 255, 255 ); 红色 从一个颜色值中获取RGB三色: int nRed = GetRValue( DWord rgb ) int nGreen = GetGValue( DWord rgb ) int nBlue = GetBVakue( DWord rgb ) 1.3 点的绘制和获取 绘制: SetPixel 获取: GetPixel MoveToEx移动当前点到指定位置 LineTo 从当前点绘制之前到指定位置 1.5 弧的绘制
Arc和AngleArc提供不同的绘制弧的方式
1.6 折线 Win32 Windows编程 十,搜素材,soscw.com Win32 Windows编程 十 标签:win32 图形 mfc sdk c++ 原文地址:http://blog.csdn.net/ctxbloger/article/details/37922391COLORREF SetPixel(
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos, // y-coordinate of pixel
COLORREF crColor // 颜色值
);
COLORREF GetPixel(
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
1.4 直线的绘制
BOOL AngleArc(
HDC hdc, // handle to device context
int X, // x-coordinate of circle‘s center 圆心x坐标
int Y, // y-coordinate of circle‘s center 圆心y坐标
DWORD dwRadius, // circle‘s radius 园的半径
FLOAT eStartAngle, // arc‘s start angle 开始角度
FLOAT eSweepAngle // arc‘s sweep angle 夹角
);
圆弧的切割方式
int SetArcDirection(
HDC hdc, // handle to device context
int ArcDirection // new arc direction
);
BOOL Arc(
HDC hdc, // handle to device context
int nLeftRect, // x-coord of rectangle‘s upper-left corner
int nTopRect, // y-coord of rectangle‘s upper-left corner
int nRightRect, // x-coord of rectangle‘s lower-right corner
int nBottomRect, // y-coord of rectangle‘s lower-right corner 外切矩形的坐标
int nXStartArc, // x-coord of first radial ending point
int nYStartArc, // y-coord of first radial ending point
int nXEndArc, // x-coord of second radial ending point
int nYEndArc // y-coord of second radial ending point
);
BOOL Polyline(
HDC hdc, // handle to device context
CONST POINT *lppt, // array of endpoints
int cPoints // number of points in array
);
BOOL PolylineTo(
HDC hdc, // handle to device context
CONST POINT *lppt, // array of points
DWORD cCount // number of points in array
); 与PolyLine类似, 在绘制PolyLine前,从当前点使用LineTo绘制直线到Polyline的第一个顶点