一 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. 熬之滴水成石:最想深入了解的内容--windows内核机制(15)

    66--内存管理(4) 说说在windows中内存空间初始化的事,开始的开始通过处理器的分页机制,预先建立相应足够的页表以便页表来访问物理内存.预先建立的这个物理内存的是windows自己的加载程序, ...

  2. Java内部类——局部内部类

    局部内部类,即放在“{块中}”,局部内部类,不能被成员修饰符static修饰,且内部类的成员也不能是static. 内部类中访问局部变量“{块中}”,需要将局部变量声明为final. 可以直接访问外部 ...

  3. Linux下使用Mysql

    一.连接MySQL数据库 一个最简单的程序示例: #include <stdio.h> #include "mysql.h" int main() { MYSQL my ...

  4. Android开发之导入错误

    在导入Git库中更新下来的project的时候,自己手动的加入libs,assets等依赖库进去.可是导入project总是会莫名奇异的出现故障,特别是对Android系统库依赖的报错之类的. 解决方 ...

  5. ios-王云鹤 调用ios系统功能---------------打电话、发短信、发邮件

    --------------------------------------菜鸟总结,欢迎读者雅正------------------------------------------------- 先 ...

  6. C# - 使用 List<> 泛型给GridView控件数据

    创建实体模型: namespace Test.Models { public class Student { public string ID { get; set; } public string ...

  7. Linux - VIM(VI)编辑器

    VIM(VI)编辑器 简介: VI是一个命令行界面下的文本编辑工具,最早在1976年BILL Joy开发,当时的名字叫做ex.VI支持绝大多数操作系统(最早在BSD上发布),并且功能已经十分强大. 1 ...

  8. Eclipse ADT 更换主题

    如果Eclipse 版本3.6以上 在 Help→Eclipse Marketplace 搜索 Theme 之后安装即可 如果Eclipse版本3.5 一下, 通过地址安装插件: http://ecl ...

  9. TTL 超时问题

    在TCP/IP网络中,网络层并不对数据包进行可靠性传输保证,只通过ICMP报文提供反馈机制(例如:差错控制).PING命令就是ICMP的请求/响应报文,也是网络最常用的测试手段.通常使用PING命令测 ...

  10. Atitit.jquery 版本号新特性attilax总结

    Atitit.jquery 版本号新特性attilax总结 1. Jq1.4 1 2. 1.5 1 3. 1.6 3 4. Jq1.7 3 ⒉提升了事件委派时的性能有了大幅度的提升.尤其是在ie7下: ...