Win32 Windows编程 十
一 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编程 十的更多相关文章
- Win32 Windows编程 十二
一.对话框 1.对话框的分类 2.对话框的基本使用方式 3.对话框资源 4.有模式对话框的使用 5. 无模式对话框的使用 5.1 加入对话框资源 5.2 定义窗体处理函数 BOOL CALLBACK ...
- Win32 Windows编程 九
资源的使用 1 资源文件 图标 光标 字符串 菜单 加速键 对话框资源位图等等 资源脚本文件 - 扩展名为RC文件 定义了资源和相关文件等信息 资源编译器 - RC.exe 2 图标资源 ICON ...
- Win32 Windows编程 七
定时器消息 1. WM_TIMER 依照定时器设置的时间段,自己主动向窗体发送一个定时器消息WM_TIMER.优先级比較低 定时器精度比較低.毫秒级别.消息产生时间也精度比較低 2 .消息和函数 WM ...
- 【Windows编程】系列第十篇:文本插入符
大家知道,在使用微软的编程环境创建工程时会让你选择是控制台模式还是Windows应用程序.如果选择控制台的console模式,就会在运行时出现一个黑洞洞的字符模式窗口,里面就有等待输入一闪一闪的插入符 ...
- 【Windows编程】系列第五篇:GDI图形绘制
上两篇我们学习了文本字符输出以及Unicode编写程序,知道如何用常见Win32输出文本字符串,这一篇我们来学习Windows编程中另一个非常重要的部分GDI图形绘图.Windows的GDI函数包含数 ...
- 【Windows编程】系列第六篇:创建Toolbar与Statusbar
上一篇我们学习了解了如何使用Windows GDI画图,该应用程序都是光光的静态窗口,我们使用Windows应用程序,但凡稍微复杂一点的程序都会有工具栏和状态栏,工具栏主要用于一些快捷功能按钮.比如典 ...
- 【Windows编程】系列第八篇:通用对话框
上一篇我们学习了菜单的基本编程,本篇来了解一下通用对话框的使用.Windows系统之所以是目前最流行的桌面系统,也是因为Windows有一套标准化,统一友好的交互界面,比如菜单.工具栏.状态栏以及各个 ...
- 【Windows编程】系列第九篇:剪贴板使用
上一篇我们学习了常见的通用对话框,本篇来了解剪贴板的使用,它常用于复制粘贴功能. 剪贴板是Windows最早就加入的功能,由于该功能非常实用,我们几乎每天都会使用到.通过剪贴板,我们就可以将数据从一个 ...
- 【Windows编程】系列第三篇:文本字符输出
上一篇我们展示了如何使用Windows SDK创建基本控件,本篇来讨论如何输出文本字符. 在使用Win32编程时,我们常常要输出文本到窗口上,Windows所有的文本字符或者图形输出都是通过图形设备接 ...
随机推荐
- 信号槽所用的参数类型,必须是Qt能认识的元类型,否则就要调用Q_DECLARE_METATYPE和qRegisterMetaType进行注册
虽然上面部分中的声明使类型可以在direct信号槽连接中使用,但是无法用于queued信号槽连接中 http://blog.csdn.net/u011012932/article/details/52 ...
- 【图像识别】 图像处理和图像分析(leptonica)leptonica-1.68安装配置 (vs2008)
Leptonica Leptonica is a pedagogically-oriented open source site containing software that is broadly ...
- android用shape画虚线,怎么也不显示
一直以为android的shape能画直线.虚线.矩形,圆形等.画直线也就算了.用一个view设一下高度和颜色,就能够出来一条直线了.所以说这个对我来说常常不用,圆形是能够,看看我应用里的消息提 ...
- javaEE开发之导出excel工具类
web开发中,一个系统的普通需求也包含导出excel,一般採用POI做统计报表导出excel. 导出excel工具类: import java.io.FileOutputStream; import ...
- 浅谈sqlldr
1.安装oracle sqlldr 2.配置sqlldr环境 3java代码的实现 在windows下面sqlldr: sqlldr = “cmd /c start D:/oracle/produ ...
- Thinkphp入门 一 (45)
原文:Thinkphp入门 一 (45) 什么是框架? 就是一堆代码的集合,这些代码可以有变量.常量.函数.类等等.这些代码彼此紧密联系,彼此有合作关系.里边还有设计模式:MVC.单例.工厂等等. 为 ...
- POJ2031Building a Space Station (最小生成树之prim)
Problem Description You are a member of the space station engineering team, and are assigned a task ...
- 从头学起android<AudioManager 声音编辑器.五十.>
我们用android经常使用的时候,手机的声音增大和缩小操作.在设定场景模式,它往往使用静音和振动运行,这通常是AudioManager来控制的. 今天我们就来看一下AudioManager 的使用. ...
- mysql sql执行顺序
<pre name="code" class="html">mysql> explain select * from (select * fr ...
- CentOS6.4 编译安装Python 3.3.2 - CRPER木木
基础环境: CentOS6.4(预装GCC,或者联网YUM---GCC编译写进这里太臃肿,找机会另外写一篇) Python 3.3.2 下载链接: http://www.python.org/ ...