一 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

COLORREF SetPixel(
HDC
hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos, // y-coordinate of pixel
  COLORREF crColor // 颜色值
);

获取: GetPixel

COLORREF GetPixel(
HDC
hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);

1.4 直线的绘制

MoveToEx移动当前点到指定位置

LineTo 从当前点绘制之前到指定位置

1.5 弧的绘制

Arc和AngleArc提供不同的绘制弧的方式

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
);

1.6 折线

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的第一个顶点
BOOL PolyPolyline(
HDC
hdc, // handle to device context
CONST POINT *lppt, // array of points 全部点的数组
CONST DWORD *lpdwPolyPoints, // array of values 每组点的数量
DWORD cCount // number of entries in values array 分组的数量
);

1.7 Bizer曲线

BOOL PolyBezier(
HDC
hdc, // handle to device context
CONST POINT* lppt, // endpoints and control points 点数组
DWORD cPoints // count of endpoints and control points 点的数量
);

1.8 圆角矩形

BOOL RoundRect(
HDC
hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect, // y-coord of lower-right corner of rectangle
int nWidth, // width of ellipse 生成圆角的椭圆的宽度
int nHeight // height of ellipse 生成圆角的椭圆的高度
);

1.9 矩形

BOOL Rectangle(
HDC
hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect // y-coord of lower-right corner of rectangle
);

1.10 椭圆

BOOL Ellipse(
HDC
hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect // y-coord of lower-right corner of rectangle
);

1.11 pie饼

BOOL Pie(
HDC
hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect, // y-coord of lower-right corner of rectangle
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
);

1.12 弦

BOOL Chord(
HDC
hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect, // y-coord of lower-right corner of rectangle
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
);

1.13 多变形

BOOL Polygon(
HDC
hdc, // handle to DC
CONST POINT *lpPoints, // polygon vertices
int nCount // count of polygon vertices
);

2 GDI画图对象 - 画笔

2.1 画笔的作用

能够控制线条的颜色、样式、宽度

2.2 画笔的使用

创建画笔

CreatePen

置成当前DC能够使用的画笔

SelectObject

绘制图形

从当前DC中取出画笔

SelectObject

销毁画笔

DeleteObject

3 GDI画图对象 - 画刷

3.1 画刷的作用

填充封闭图形,包含样式 颜色

3.2 画刷的使用

创建画刷

CreateSilidBrush

CreateHatchBrush

置成当前DC能够使用的画刷

SelectObject

绘制图形

取出画刷

SelectObject

销毁画刷

DeleteObject

Win32 Windows编程 十的更多相关文章

  1. Win32 Windows编程 十二

    一.对话框 1.对话框的分类 2.对话框的基本使用方式 3.对话框资源 4.有模式对话框的使用 5. 无模式对话框的使用 5.1 加入对话框资源 5.2 定义窗体处理函数 BOOL CALLBACK ...

  2. Win32 Windows编程 九

    资源的使用 1 资源文件 图标 光标 字符串 菜单  加速键 对话框资源位图等等 资源脚本文件 - 扩展名为RC文件 定义了资源和相关文件等信息 资源编译器 - RC.exe 2 图标资源 ICON ...

  3. Win32 Windows编程 七

    定时器消息 1. WM_TIMER 依照定时器设置的时间段,自己主动向窗体发送一个定时器消息WM_TIMER.优先级比較低 定时器精度比較低.毫秒级别.消息产生时间也精度比較低 2 .消息和函数 WM ...

  4. 【Windows编程】系列第十篇:文本插入符

    大家知道,在使用微软的编程环境创建工程时会让你选择是控制台模式还是Windows应用程序.如果选择控制台的console模式,就会在运行时出现一个黑洞洞的字符模式窗口,里面就有等待输入一闪一闪的插入符 ...

  5. 【Windows编程】系列第五篇:GDI图形绘制

    上两篇我们学习了文本字符输出以及Unicode编写程序,知道如何用常见Win32输出文本字符串,这一篇我们来学习Windows编程中另一个非常重要的部分GDI图形绘图.Windows的GDI函数包含数 ...

  6. 【Windows编程】系列第六篇:创建Toolbar与Statusbar

    上一篇我们学习了解了如何使用Windows GDI画图,该应用程序都是光光的静态窗口,我们使用Windows应用程序,但凡稍微复杂一点的程序都会有工具栏和状态栏,工具栏主要用于一些快捷功能按钮.比如典 ...

  7. 【Windows编程】系列第八篇:通用对话框

    上一篇我们学习了菜单的基本编程,本篇来了解一下通用对话框的使用.Windows系统之所以是目前最流行的桌面系统,也是因为Windows有一套标准化,统一友好的交互界面,比如菜单.工具栏.状态栏以及各个 ...

  8. 【Windows编程】系列第九篇:剪贴板使用

    上一篇我们学习了常见的通用对话框,本篇来了解剪贴板的使用,它常用于复制粘贴功能. 剪贴板是Windows最早就加入的功能,由于该功能非常实用,我们几乎每天都会使用到.通过剪贴板,我们就可以将数据从一个 ...

  9. 【Windows编程】系列第三篇:文本字符输出

    上一篇我们展示了如何使用Windows SDK创建基本控件,本篇来讨论如何输出文本字符. 在使用Win32编程时,我们常常要输出文本到窗口上,Windows所有的文本字符或者图形输出都是通过图形设备接 ...

随机推荐

  1. Qt之多线程

    源地址:http://blog.csdn.net/liuhongwei123888/article/details/6072320 Qt 是一种基于 C++ 的跨平台 GUI 系统,能够提供给用户构造 ...

  2. 【Demo 0009】Android 组件(BroadcastReceiver)

    本章学习要点:        1.  了解Broadcast的作用;        2.  掌握自定义广播和系统广播的接收:        3.  掌握广播的发送:

  3. 火炬之光模型导出(Unity载入火炬之光的模型)

    先说明几点.导出方案可行,測试通过. python和blender的版本号一定要用下文中所说的.新的Python或者是新的Blender版本号都无法完美导入. 导入导出脚本能够选择 (http://c ...

  4. Mac下MAMP初试体验

    原创文章,转载请注明出处! 近期小学习了一下Mac下的Apache,Mysql,php.这里记录一下,以备忘 1 php 1.1 php返回值的測试 在MAMP下測试成功,直接echo返回所数据 1. ...

  5. libcurl编程,整整17篇

    http://www.cnblogs.com/lidabo/category/639633.html

  6. Spring MVC RedirectAttributes的用法解决办法

    Spring MVC RedirectAttributes的用法很久没发过技术贴了,今天对于一个问题纠结了2小时,遂放弃研究用另一种方法解决,奈何心中一直存在纠结,发帖求解 我先解释下什么是Redir ...

  7. jQuery事件大全

    jQuery事件大全 attribute:  $(" p" ).addclass(css中定义的样式类型) 给某个元素添加样式 $(" img" ).attr( ...

  8. 5.中文问题(自身,操作系统级别,应用软件的本身),mysql数据库备份

     第一层因素: mysql的自身的设置 mysql有六处使用了字符集.分别为:client .connection.database.results.server .system. mysql&g ...

  9. 我在知乎上关于Laser200/310电脑的文章。

    我是30年前从Laser-310起步的,我来回答这个问题. 主要硬件规格: CPU:Z-80A/4.7MHz主频 16K RAM + 2K Video RAM 16K ROM 磁带输出:波特率300 ...

  10. CMDeviceMotion使用

    CMDeviceMotion使用 by 吴雪莹 manager = [[CMMotionManager alloc] init]; ViewController *__weak weakSelf=se ...