Presentation is loading. Please wait.

Presentation is loading. Please wait.

一个简单的二维光栅图形软件包:Windows API

Similar presentations


Presentation on theme: "一个简单的二维光栅图形软件包:Windows API"— Presentation transcript:

1 一个简单的二维光栅图形软件包:Windows API
Thank you for your time today. Believe I have a lot of good information to share with you today – it’s been just a little over a year since we introduced the notion of e-business on demand – know that there’s been a lot written about it … lots of competitors have begun to describe notions that sound very similar. Today I want to spend the majority of our time together moving the discussion from the what and why of becoming an on demand business to the how – to some very concrete essentials, methodologies and offerings that we’ve spent the last year developing. But before I get into specifics on the how to – I do want to spend a few minutes up front – setting a little context. 2019/5/6 IBM Confidential

2 Windows API 内容概要 1)用图形软件包绘图 2)基本的交互处理 3)光栅操作 应用 模型 程序 图形 硬件 设备 输出流 输入流
2019/5/6

3 Windows API :用图形软件包绘图 包含内容: 图元的声明 图元的属性 填充图元及属性 保存和恢复图元的属性 字符 2019/5/6

4 Windows API - 用图形软件包绘图(1)
图元的声明 绘图纸,屏幕,坐标系 扫描转换 顶点(参数) 表示的图形 用户 点阵表示 的图形 显示系统 扫描转换:转换为点阵表示的图形 2019/5/6

5 Windows API - 用图形软件包绘图 (2)
基本图元绘制:点、直线段、折线、多边形、圆弧、字符。 COLORREF GetPixel( int x, int y ) const COLORREF SetPixel( int x, int y, COLORREF crColor ); 直线段 CPoint MoveTo( int x, int y ); BOOL LineTo( int x, int y ); 折线 BOOL Polyline( LPPOINT lpPoints, int nCount ); 2019/5/6

6 Windows API - 用图形软件包绘图 (3)
点圆弧 BOOL AngleArc( int x, int y, int nRadius, float fStartAngle, float fSweepAngle ); 椭圆弧 BOOL Arc( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 ); (x3,y3) (x4,y4) 2019/5/6

7 Windows API - 用图形软件包绘图 (4)
图元的属性 图元在显示时被扫描转换成离散的像素写入帧缓冲器中,线型控制可看作有选择地写像素的位屏蔽器(bit marker). 位屏蔽器为‘0’表示帧缓存中相应的像素值不变(即透明),为‘1’表示用线段的颜色值代替帧缓存中相应的像素值。 线型、线宽 CPen ( int nPenStyle, int nWidth, COLORREF crColor ); BOOL CreatePen (int nPenStyle,int nWidth, COLORREF crColor); 颜色 三种指定颜色的方式 通过查色表索引值; 通过颜色名称;如:BLUE 通过红、绿、兰 三分量;如:RGB(255,0,0) COLORREF GetBkColor( ) const; COLORREF SetBkColor( COLORREF crColor ); COLORREF GetTextColor( ) const; COLORREF SetTextColor( COLORREF crColor ); 2019/5/6

8 Windows API - 用图形软件包绘图 (5)
填充图元及其属性 封闭的图元有二种绘制方式:线画图(只画边框)和填充图(填充内部区域); 椭圆 BOOL Ellipse( int x1, int y1, int x2, int y2 ); BOOL Pie( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 ); 多边形 BOOL Polygon( LPPOINT lpPoints, int nCount ); 矩形 BOOL Rectangle( int x1, int y1, int x2, int y2 ); 填充模式 均匀填色 BOOL CreateSolidBrush( COLORREF crColor ); 以图像填充 BOOL CreatePatternBrush( CBitmap* pBitmap ); 2019/5/6

9 Windows API - 用图形软件包绘图 (6)
填充图元、保存和恢复图元的属性: 目的:为了提高程序的模块化程度 字符 属性:字体(宋体,楷体…)、字形(粗体,斜体…)、字型(7 X 9,16 X 24…)、字间距、行间距。 BOOL TextOut( int x, int y, LPCTSTR lpszString, int nCount ); 2019/5/6

10 Windows API - 基本的交互处理 (1)
基本原则 逻辑输入设备 输入方式 事件驱动方式 2019/5/6

11 Windows API - 基本的交互处理 (2)
几条原则 简单一致的交互操作序列(Menu, Button); 交互的每各阶段,清晰的可选项; 样式简洁,选项有层次、简单,不能有过多选项; 给用户适当反馈(highlight,光标形状…); 允许用户取消操作(Undo); 解决方法: 菜单、 按钮、 加亮、 变灰、 光标变化等等 逻辑输入设备 目标:屏蔽物理设备的差异,实现系统的设备无关性与软件可移植性; 二维定位设备; 键盘设备; 设备驱动程序完成从物理设备到逻辑设备的映射或逆过程; 2019/5/6

12 Windows API - 基本的交互处理 (3)
输入方式 取样输入设备的状态,效率不高 中断驱动:何时处理中断?增加程序设计难度 事件驱动:后台监控程序,事件队列。主动处理 取样(轮询)方式 中断驱动方式 事件驱动方式 2019/5/6

13 Windows API - 基本的交互处理 (4)
事件驱动方式 程序结构简单 初始化; Do{ waitEvent(event); Switch(event) { Case EVENT1: precedure1; break; Case EVENT2: procedure2; } }while(TRUE); 2019/5/6

14 Windows API - 光栅操作(0) 画布 裁剪窗 位块拷贝 显示模式 2019/5/6

15 用于保存菜单和屏幕上一块图像的图元称为画布
Windows API - 光栅操作(1) 画布(Canvas) 抽象的数据类型,用户可以在其中画图; 包括一个像素图和一些控制信息; 具有独立的坐标系; 系统可以同时有多个画布,只有一个处于激活状态; 屏幕是一个特殊的画布; 绘图命令的作用对象是处于激活状态的画布; Windows中对应的概念:DC 举例:如图 用于保存菜单和屏幕上一块图像的图元称为画布 2019/5/6

16 Windows API - 光栅操作(2) 裁剪窗口 为什么裁剪? 内裁剪:保留窗口之内的图形; 外裁剪:保留窗口之外的图形;
UINT SetBoundsRect( LPCRECT lpRectBounds, UINT flags ); UINT GetBoundsRect( LPRECT lpRectBounds, UINT flags ); 2019/5/6

17 Windows API - 光栅操作(3) 位块拷贝 (x,y) (xSrs,ySrc)
BitBlt(Bit Block Transfer) BOOL BitBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop ); (x,y) (xSrs,ySrc) 2019/5/6

18 Windows API - 光栅操作(4) 显示模式 为什么有显示模式? 四种简单的显示模式: 覆盖/Replace 或/Or 异或/Xor
与/And 2019/5/6

19 Windows API - 光栅操作(5) Windows中的显示模式 int GetROP2( ) const;
int SetROP2( int nDrawMode ); R2_BLACK   R2_WHITE  R2_NOP   R2_NOT    R2_COPYPEN  R2_NOTCOPYPEN    R2_MERGEPENNOT  R2_MASKPENNOT  R2_MERGENOTPEN  R2_MASKNOTPEN    R2_MERGEPEN   R2_NOTMERGEPEN    R2_MASKPEN    R2_NOTMASKPEN   R2_XORPEN  R2_NOTXORPEN 2019/5/6

20 Windows API - 光栅操作(5) 异或的用途:光标的显示 11001001 Xor 11111111
光栅运算同样适用于 多值图像,表现为相 应单元间的按位逻辑 运算; 2019/5/6

21 Thank you! Best Wishes! 2019/5/6


Download ppt "一个简单的二维光栅图形软件包:Windows API"

Similar presentations


Ads by Google