{设备管理}设备描述表概述

上传人:冯** 文档编号:140454599 上传时间:2020-07-29 格式:PPTX 页数:91 大小:697.89KB
返回 下载 相关 举报
{设备管理}设备描述表概述_第1页
第1页 / 共91页
{设备管理}设备描述表概述_第2页
第2页 / 共91页
{设备管理}设备描述表概述_第3页
第3页 / 共91页
{设备管理}设备描述表概述_第4页
第4页 / 共91页
{设备管理}设备描述表概述_第5页
第5页 / 共91页
点击查看更多>>
资源描述

《{设备管理}设备描述表概述》由会员分享,可在线阅读,更多相关《{设备管理}设备描述表概述(91页珍藏版)》请在金锄头文库上搜索。

1、第4章 设备描述表,4.1 设备描述表概述 4.2 映射模式 4.3 GDI对象 4.4 设备描述表属性,4.1 设备描述表,设备描述表(Device Context) 一种Windows数据结构,用来描述绘制窗口所需要的信息。 它定义了坐标映射模式、一组GDI图形对象及其属性。 GDI对象 画线的笔,绘图填图的刷子,位图,调色板,剪裁区域,及路径(Path)。,设备描述表分类,设备描述表属性,4.1.1 设备描述表的使用步骤,设备描述表的使用步骤: 获取或者创建设备描述表; 必要的话,改变设备描述表的属性; 使用设备描述表完成绘制操作; 释放或删除设备描述表。,获取和释放设备描述表,1 WM

2、_PAINT消息( CWnd类OnPaint函数) CPaintDC dc(this); hdc = BeginPaint (hwnd, ,设置设备描述表的属性,设备描述表属性的表示 复杂GDI对象:如画笔、画刷、位图、调色板等。 简单MFC类对象:如裁剪区域,原点。 简单变量:字体颜色、背景颜色等。 一组符号常量:如各种模式,绘制模式,背景模式和填充模式等。 设置设备描述表属性的方式 选入选出方式:在处理事件期间选入,事件处理完毕后选出。 状态机方式:按需要随时设置。,设置设备描述表的属性,设备描述表属性的保持问题 通常情况下,在一个事件函数中设置的设备描述表属性通常不能保存到下一个消息函数

3、,所以对于每一个消息函数,都应该在使用设备描述表之前都要重新进行设置。 但windows提供了保持设备描述表属性的机制,设备描述表的保持机制,设备描述表的保持机制 自动保存:每次设置的属性均保存在windows设备描述表中。 创建窗口时(WM_CREATE消息),设置CS_OWNDC风格。 动态管理机制: 使用下列一组API函数管理设备描述表属性。 保存/恢复设备上下文。 idSaved = SaveDC (hdc) ; 改变一些属性 ;RestoreDC (hdc, idSaved) ; 以堆栈方式使用SaveDC和RestoreDC SaveDC (hdc) ; RestoreDC (hd

4、c, -1) ; 或使用CDC类成员函数管理设备描述表属性。 保存/恢复设备上下文。 idSaved = SaveDC () ; 改变一些属性 ;RestoreDC ( idSaved) ; 以堆栈方式使用SaveDC和RestoreDC SaveDC () ; RestoreDC (-1) ;,4.1.2 设备描述表的绘图函数,点 COLORREF GetPixel( int x, int y ) const; COLORREF GetPixel( POINT point ) const; COLORREF SetPixel( int x, int y, COLORREF crColor )

5、; COLORREF SetPixel( POINT point, COLORREF crColor ); BOOL SetPixelV( int x, int y, COLORREF crColor ); BOOL SetPixelV( POINT point, COLORREF crColor ); 直线 CPoint MoveTo( int x, int y ); CPoint MoveTo( POINT point ); BOOL LineTo(int x,int y); BOOL LineTo( POINT point ); 弧 BOOL AngleArc( int x, int y

6、, int nRadius, float fStartAngle, float fSweepAngle ); BOOL Arc( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 ); BOOL Arc( LPCRECT lpRect, POINT ptStart, POINT ptEnd ); BOOL ArcTo( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 ); BOOL ArcTo( LPCRECT lpRect, POINT p

7、tStart, POINT ptEnd ); int SetArcDirection( int nArcDirection ); int GetArcDirection( ) const;,4.1.2 设备描述表的绘图函数,BeZier曲线: BOOL PolyBezier( const POINT* lpPoints, int nCount ); BOOL PolyBezierTo( const POINT* lpPoints, int nCount ); BOOL PolyDraw( const POINT* lpPoints, const BYTE* lpTypes, int nCoun

8、t ); BOOL Polyline( LPPOINT lpPoints, int nCount ); BOOL PolylineTo( const POINT* lpPoints, int nCount ); BOOL PolyPolyline( const POINT* lpPoints, const DWORD* lpPolyPoints, int nCount ); 位图 BOOL AlphaBlend( int xDest, int yDest, int nDestWidth, int nDestHeight, CDC* pSrcDC, int xSrc, int ySrc, int

9、 nSrcWidth, int nSrcHeight, BLENDFUNCTION blend ); BOOL BitBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop ); BOOL MaskBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, CBitmap,4.1.2 设备描述表的绘图函数,矩形 void Draw3dRect( LPCRECT lpRect, CO

10、LORREF clrTopLeft, COLORREF clrBottomRight ); void Draw3dRect( int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight ); void DrawDragRect( LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast, CBrush* pBrush = NULL, CBrush* pBrushLast = NULL ); BOOL DrawEdge( LPRECT lpRe

11、ct, UINT nEdge, UINT nFlags ); void FillRect( LPCRECT lpRect, CBrush* pBrush ); void FillSolidRect( LPCRECT lpRect, COLORREF clr ); void FrameRect( LPCRECT lpRect, CBrush* pBrush ); void InvertRect( LPCRECT lpRect ); BOOL Rectangle( int x1, int y1, int x2, int y2 ); BOOL Rectangle( LPCRECT lpRect );

12、 BOOL RoundRect( LPCRECT lpRect, POINT point ); void DrawFocusRect( LPCRECT lpRect );,4.1.2 设备描述表的绘图函数,多边形 BOOL Polygon( LPPOINT lpPoints, int nCount ); BOOL PolyPolygon( LPPOINT lpPoints, LPINT lpPolyCounts, int nCount ); BOOL Polyline( LPPOINT lpPoints, int nCount ); 椭圆 BOOL Ellipse( int x1, int y

13、1, int x2, int y2 ); BOOL Ellipse( LPCRECT lpRect ); 扇形 BOOL Chord( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 ); BOOL Chord( LPCRECT lpRect, POINT ptStart, POINT ptEnd ); BOOL Pie( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 ); BOOL Pie( LPCRECT lpRect, POINT

14、ptStart, POINT ptEnd );,4.1.2 设备描述表的绘图函数,文字 virtual int DrawText( LPCTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat ); int DrawText( const CString,4.1.2 设备描述表的绘图函数,区域: BOOL FillRgn( CRgn* pRgn, CBrush* pBrush ); BOOL FrameRgn( CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight ); BOOL Inv

15、ertRgn( CRgn* pRgn ); BOOL PaintRgn( CRgn* pRgn ); BOOL ExtFloodFill( int x, int y, COLORREF crColor, UINT nFillType ); BOOL FloodFill( int x, int y, COLORREF crColor ); BOOL GradientFill( TRIVERTEX* pVertices, ULONG nVertices, void* pMesh, ULONG nMeshElements, DWORD dwMode ); 路径 BOOL BeginPath(); B

16、OOL EndPath( ); BOOL CloseFigure( ); BOOL FillPath( ); BOOL FlattenPath( ); int GetPath( LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const; BOOL SelectClipPath( int nMode ); BOOL StrokeAndFillPath( );,4.2 映射模式,映射模式: 逻辑坐标和设备坐标的映射方式。 设备坐标: 设备使用的整数坐标,与设备相关。 逻辑坐标: GDI函数使用的实数坐标,与设备无关。,4.2 映射模式,视口(view port) 设备上的一个矩形区域,使用设备坐标。通常和显示区域相同。 实际设备使用的坐标 视口的指标 视口原点(0,0)和视口范围(1,1)和坐标轴方向。 窗口(window) 用户图形(与现实世界中的实体相对应)使用的矩形区域,使用逻辑坐标,可以用图素、毫米、英寸或任何其它单位。 GDI绘图函数中使用窗口坐标。 窗口的表示 窗口原点(0,0)窗口范围(1,1)和坐标轴方向,4.2.1 坐标变换公

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 企业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号