(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象

上传人:zhuma****mei1 文档编号:54243232 上传时间:2018-09-10 格式:DOC 页数:9 大小:90.50KB
返回 下载 相关 举报
(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象_第1页
第1页 / 共9页
(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象_第2页
第2页 / 共9页
(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象_第3页
第3页 / 共9页
(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象_第4页
第4页 / 共9页
(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象》由会员分享,可在线阅读,更多相关《(毕业论文)-外文翻译--设备环境DC及图形设备接口(GDI)对象(9页珍藏版)》请在金锄头文库上搜索。

1、毕业设计毕业设计( (论文论文) )外文资料翻译外文资料翻译外文出处外文出处: Advanced MFC Programming 附附 件:件: A.外文翻译 -原文部分 B.外文翻译 -译文部分 指导教师评语:签名: 年 月 日(用外文写)附录附录A.A.外文翻译外文翻译 - -原文部分原文部分( (写明出处写明出处) ) Advanced MFC Programming Chapter 8:DC, Pen, Brush and Palette 8.0 Device Context how to change the text alignment; how to add special ef

2、fects to characters. When we implement a font dialog box, all the available fonts contained in the system will be listed in it. We can select font size, font name, special styles, and text color.Like other GDI objects such as pen and brush, we need to create font with specific styles and select it i

3、nto a DC in order to use it for outputting text. In MFC, the class that can be used to implement font is CFont. To create a font, we can call either CFont:CreateFont() or CFont:CreateFontIndirect(), whose formats are listed as follows: BOOL CFont:CreateFont ( int nHeight, int nWidth, int nEscapement

4、, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename );BOOL CFont:CreateFontIndirect(const LOGFONT *lpLogFont); The first function has many parameters and the

5、 second one needs only a LOGFONT type pointer. The results of the two member functions are exactly the same, every style we need to specify for a font in the first function has a corresponding member in structure LOGFONT: typedef struct tagLOGFONT LONG lfHeight; LONG lfWidth; LONG lfEscapement; LONG

6、 lfOrientation; LONG lfWeight; BYTE lfItalic; BYTE lfUnderline; BYTE lfStrikeOut; BYTE lfCharSet; BYTE lfOutPrecision; BYTE lfClipPrecision; BYTE lfQuality; BYTE lfPitchAndFamily; TCHAR lfFaceNameLF_FACESIZE; LOGFONT; Here, member lfFaceName specifies the font name; lfHeight and lfWidth specify font

7、 size; lfWeight,lfItalic, lfUnderline and lfStrikeOut specify font styles. Besides these styles, there are two other styles that can be specified: lfEscapement and lfOrientation. If they are non-zero, the text will have an angle with respect to the horizontal border of the window when it is displaye

8、d . To display text this way, we must assign the angle to both lfEscapement and lfOrientation when creating the font, the unit of the angle is one tenth of a degree. Please note that only True Type fonts can have such orientation.Summary:1 Before drawing anything to a window, we must first obtain it

9、s device context. There are many ways of obtaining a windows DC (Calling function CWnd:GetDC(), declaring CClientDC or CWindowDC type variables, etc.). 2 A client DC can be used to paint a windows client area, and a window DC can be used to paint the whole window (client and non-client area). 3 Pen

10、can be used to draw line, the border of rectangle, polygon, ellipse, etc. A pen can have different styles: solid pen, dashed pen, etc. 4 Brush can be used to fill the interior of rectangle, polygon, ellipse, etc. A brush can have different patterns: solid, hatched, etc. 5 We can use an 88 image to c

11、reate pattern brush. 6On a palette device, there are two color approaching methods: dithering and using the nearest color. 7The abilities of a device can be retrieved by calling function CDC:GetDeviceCaps().附录附录B.B. 外文翻译外文翻译 - -译文部分译文部分节选自节选自Advanced MFC Programming第八章第八章DC, Pen, Brush and Palette8.

12、0 节:设备环境节:设备环境 DC 及及 图形设备接口(图形设备接口(GDI)对象)对象从这一章开始,我们将要学习图形设备接口 GDI 编程。概述概述图形设备接口(GDI)是在程序员和物理设备之间的一个标准的接口。它提供了许多函数,调用这些函数可以将图形绘制在硬件(如显示器或打印机)上。可见图形设备接口GDI 非常重要,因为作为一个程序员,我们也许需要应用程序能适用于尽可能多的外围设备。举例来说,几乎每个应用软件都需要在显示器显示数气,而且同样多数应用软件也需要支持打印机输出。现在问题出现在这里:由于一个应用程序应该能支持不同的设备,而让程序员知晓每一个外围设备的细节并且事先写代码支持它,这几

13、乎是一件不可能的事。解决方案是在设备和程序员之间引入图形设备接口GDI,它是一个标准的接口,有了它程序员可以不需要有任何的硬件设备知识就能实现对硬件的操作(输出)。只要硬件设备支持标准的图形设备接口GDI,应用程序就能正确的执行。设备环境(设备环境(DCDC)作为一个程序员,我们不需要直接输出(应用程序的输出)到硬件设备诸如:显示器或打印机。而是输出到一个虚拟逻辑设备,由它来实现我们对物理设备输出的意图。这个虚拟逻辑设备就是设备环境DC,它是一个Windows数据结构,该结构包含向有关设备输出所需的信息。当我们调用一个标准的GDI 函数时,设备环境依照物理设备的属性和配置来实现对其的操作。 假

14、如我们想要输出一个像素到显示的一个特定的坐标,如果我们没有图形设备接口GDI,为了实现这个简单的操作,我们需要下面的显示器信息。1. 视频设备存储配置信息。我们需要这些信息把逻辑坐标转化为物理缓存地址。2. 设备类型。如果是一个调色板设备,我们需要把一个 RGB 组合索引到一个颜色表,用颜色表来表示一个特定的颜色。而对于非调色板设备,我们能直接用RGB组合表示某种颜色。由于现实世界中的设备有多种多样,获得足够的信息以支持所有的设备对我们来说是不可能的。而由GDI函数取代由程序员处理物理设备输出,它让我们直接使用逻辑坐标和RGB组合,从而转换工作交给设备驱动来完成。图形设备接口(图形设备接口(G

15、DIGDI)对象)对象在Windows中,图形设备接口(GDI)对象是和设备环境一起实现绘图的工具。有了这些工具极大的方便了程序员。下面是一些常用的图形设备接口(GDI)对象列表:GDI对象用法: 画笔用于画线,曲线,长方形,椭圆,多角形等的边缘。 画刷用于填充长方形,椭圆,或特殊的多边形的内部。 字体用于处理多种字型以方便文本输出。 调色板用于在调色板设置上设置颜色 位图用于处理图像生成,绘制,操作等等。以上的图形设备接口(GDI)对象与设备环境一起,都是通过句柄来处理(实现)。我们可以使用对象的句柄去定义和访问对象。除句柄外,每个GDI对象还有一个相应的MFC类,以下是句柄类型及相应的MF

16、C类列表:GDI对象句柄类MFC 类 设备环境HDCCDC, CClientDC, CWindowDC, etc. 画刷HPENCPen 画刷HBRUSHCBrush 字体HFONTCFont 调色板HPALETTECPalette 位图HBITMAPCBitmap获取设备环境获取设备环境作为一个程序员,我们大多数时间的工作是要输出(数据)到一个特定的窗口,而不是整个显示器的银屏。因些就必须能系统中的任何窗口都可以获得设备环境,并且能用于调GDI函数。有许多方法可以从一个窗口获得设备环境。下面是其中一些方法的列表:1. 调用函数 CWnd:GetDC 。这个函数将返回一个CDC类指针,这个指针可用于在窗口中实现对图形的操作(输出)。2. 声明 CClientDC类型变量,并且传递一个CWnd类型指针给它的构造函数。类CClientDC

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

最新文档


当前位置:首页 > 学术论文 > 毕业论文

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