亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ch15.htm

?? 24小時(shí)精通VC
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD>		<META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1">	<TITLE>Teach Yourself Visual C++&#174; 5 in 24 Hours -- Hour 15 -- Using Bitmaps</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><H1 ALIGN="CENTER"><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"BORDER="0"><BR><FONT COLOR="#000077">Teach Yourself Visual C++&#174; 5 in 24 Hours</FONT></H1><CENTER><P><A HREF="../ch14/ch14.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch16/ch16.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <HR></CENTER><H1 ALIGN="CENTER"><FONT COLOR="#000077">- Hour 15 -<BR>Using Bitmaps</FONT></H1><P>Bitmaps are one of the most important GDI objects offered by Windows. In thishour, you will learn<UL>	<LI>The structures used by Windows bitmaps<BR>	<BR>		<LI>How to use the MFC <TT>CBitmap</TT> class to simplify bitmap handling<BR>	<BR>		<LI>How to use color palettes<BR>	<BR>		<LI>How to solve problems that occur when using 256-color bitmaps in Windows</UL><P>Bitmaps can be a complex topic--this hour presents a C++ class that greatly simplifiesthe use of bitmaps that can be used in your projects. You will use this class ina sample program that demonstrates how to handle 256-color bitmaps.<H2><FONT COLOR="#000077"><B>What Is a Bitmap?</B></FONT></H2><P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>A <I>bitmap</I> is a graphicalobject that can be used to represent an image in programs written for Windows. Usinga bitmap, an image can be easily stored, loaded, and displayed. A bitmap is onlyone of many graphical objects available when writing Windows programs. The followingare some other types of graphical objects:<UL>	<LI>Pens and brushes, used to draw lines and fill areas. Pens and brushes are covered	in detail in Hour 12, &quot;Using Pens and Brushes.&quot;<BR>	<BR>		<LI>Fonts, used to provide the characteristics for displayed text in a Windows program.	Fonts are discussed in Hour 13, &quot;Fonts.&quot;<BR>	<BR>		<LI>Icons and cursors, small bitmap images that are used for special purposes in	an application. Icons and cursors are discussed in Hour 14, &quot;Icons and Cursors.&quot;</UL><P>Bitmaps provide a flexible way to store image data in a Windows program. The datastructure used for a bitmap is straightforward and enables a wide variety of bitmaptypes to be stored.<BLOCKQUOTE>	<P><HR><B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>Although image	lists (described in Hour 17, &quot;Using Image Lists and Bitmaps&quot;) provide extra	features, usually a simple bitmap is the easiest way to display an image on the screen.	<HR></BLOCKQUOTE><H3><FONT COLOR="#000077"><B>Visual C++ Support for Bitmaps</B></FONT></H3><P>The easiest way to create a bitmap is to use an image editor like the one thatis integrated into the Developer Studio. The image editor is used in this chapterto create a bitmap that is displayed in a dialog box-based program's main dialogbox.</P><P>After you've created the bitmap using the image editor, you can manipulate itby using the MFC <TT>CBitmap</TT> class. You can load the bitmap into your programby calling the <TT>LoadBitmap</TT> member function:</P><PRE><FONT COLOR="#0066FF"><TT>bmpHello.LoadBitmap( IDB_HELLO );</TT></FONT></PRE><P>After the bitmap has been loaded, it can be displayed to any output device byusing a device context.<H3><FONT COLOR="#000077"><B>Adding a Bitmap to a Sample Project</B></FONT></H3><P>You can display a bitmap in any project that handles the <TT>WM_PAINT</TT> message.As an example, create an SDI program named Bitmap, following the steps used in Hour1, &quot;Introducing Visual C++ 5.&quot; After you have created the project, openthe resource tree by clicking the ResourceView tab in the project workspace window.</P><P>Insert a new bitmap resource into the project by right-clicking the resource treeand selecting Insert from the shortcut menu. An Insert Resource dialog box is displayed;select Bitmap and click the New button. A new bitmap will be inserted into the projectand loaded for editing.</P><P>The image editor displays a large grid that represents the bitmap surface, aswell as two dockable toolbars:<UL>	<LI>The Graphics toolbar consists of tools you can use to draw different shapes and	text.<BR>	<BR>		<LI>The Colors palette contains the colors that are available for drawing the bitmap.</UL><P>Both toolbars can be used as either floating palettes or docked toolbars.</P><P>You can change the properties for a bitmap resource by double-clicking the edgeof the bitmap grid or by right-clicking the bitmap's edge and selecting Propertiesfrom the pop-up menu. Change the name of the bitmap resource to <TT>IDB_HELLO</TT>.Select the text tool from the Graphics toolbar, and choose your favorite color fromthe Colors palette. Type a hello message, as shown in Figure 15.1.</P><P><A NAME="01"></A><A HREF="01.htm"><B>Figure 15.1.</B></A> <BR><I>The <TT>IDB_HELLO</TT> bitmap used in the Bitmap sample program.</I><BLOCKQUOTE>	<P><HR><B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>The font shown	in Figure 15.1 is 18-point Times New Roman Italic. <HR></BLOCKQUOTE><P>As with most resources, you can adjust the size of the bitmap by dragging theedges of the grid in any direction. Change the size of the bitmap so that the textfits inside the bitmap without any clipping. You can select a different font by pressingthe Font button on the text tool. Feel free to add other effects by selecting othertools from the Graphics toolbar.<BLOCKQUOTE>	<P><HR><B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>Using names that	begin with <TT>IDB_</TT> for bitmaps is a standard naming convention in Windows programming.	<HR></BLOCKQUOTE><H3><FONT COLOR="#000077"><B>Loading and Displaying a Bitmap</B></FONT></H3><P>Open the <TT>BitmapView.cpp</TT> source file, and locate the member function <TT>CBitmapView::OnDraw</TT>.The function should already contain several lines of source code, which you can replacewith the function provided in Listing 15.1.<H4><FONT COLOR="#000077">TYPE: Listing 15.1. The CBitmapView::OnDraw function, usedto display a bitmap.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CBitmapView::OnDraw(CDC* pDC)</TT><TT>{</TT><TT>    CBitmap     bmpHello;</TT><TT>    bmpHello.LoadBitmap( IDB_HELLO );</TT><TT>    // Calculate bitmap size using a BITMAP structure.</TT><TT>    BITMAP      bm;</TT><TT>    bmpHello.GetObject( sizeof(BITMAP), &amp;bm );</TT><TT>    // Create a memory DC, select the bitmap into the</TT><TT>    // memory DC, and BitBlt it into the view.</TT><TT>    CDC         dcMem;</TT><TT>    dcMem.CreateCompatibleDC( pDC );</TT><TT>    CBitmap* pbmpOld = dcMem.SelectObject( &amp;bmpHello );</TT><TT>    pDC-&gt;BitBlt( 10,10, bm.bmWidth, bm.bmHeight,</TT><TT>                 &amp;dcMem, 0,0, SRCCOPY );</TT><TT>    // Reselect the original bitmap into the memory DC.</TT><TT>    dcMem.SelectObject( pbmpOld );</TT><TT>}</TT></FONT></PRE><P>Before the bitmap is displayed in Listing 15.1, information about the bitmap iscollected using the <TT>SelectObject</TT> member function, which fills a <TT>BITMAP</TT>structure with information. Two pieces of useful information the <TT>BITMAP</TT>structure can provide are the width and height of the bitmap.</P><P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>A <I>memory device context</I>,or <I>memory DC</I>, is a memory location that allows for images to be drawn off-screen,which improves performance.</P><P>When displaying a bitmap, the bitmap is first selected into a memory DC. The <TT>BitBlt</TT>function is used to transfer the image from the memory DC to the view's device context,passed as a parameter to <TT>OnDraw</TT>. <TT>BitBlt</TT> is an abbreviation forBit-Block Transfer, which is the process used to move the image from the memory DCto the actual device context. The first two parameters passed to <TT>BitBlt</TT>are the coordinates of the destination rectangle.</P><P>When you compile and run the Bitmap project, the <TT>IDB_HELLO</TT> bitmap isdisplayed in the upper-right corner of the view window. Experiment by changing thesize and color of the bitmap or by combining the source code provided in Listing15.1 with the <TT>DrawText</TT> function.</P><P>If you experiment with the Bitmap program long enough, you might discover a problemthat occurs when using bitmaps. Although the background of the <TT>IDB_HELLO</TT>bitmap is white, it isn't transparent. If the color of the view background is grayor another color, the bitmap will look like a white square containing text. It ispossible to display a bitmap with a transparent background, although it takes a greatdeal of advanced graphics work. Fortunately, the image list, first introduced forWindows 95, has the capability to draw a transparent bitmap. Image lists are thoroughlydiscussed in Hour 17, &quot;Using Image Lists and Bitmaps.&quot;<H2><FONT COLOR="#000077"><B>DDBs Versus DIBs</B></FONT></H2><P>Bitmaps come in two basic flavors: Device-Independent Bitmaps (DIB) and Device-Dependent Bitmaps (DDB). In earlier versions of 16-bit Windows, only DDBs were supported.Beginning with Windows 3.0, and on all versions of Windows NT, DIBs are supported.<H3><FONT COLOR="#000077"><B>The DDB Problem</B></FONT></H3><P>A DDB is tightly coupled to the device on which it is intended to be displayed.The memory that is used to store the bitmap is actually allocated by the device driver,and an application that must change the contents of the bitmap must do so indirectly,a slow and inefficient process. Figure 15.2 shows how a DDB is controlled by a devicedriver and that the application has only indirect access to the bitmap.</P><P>One of the problems with DDBs is that an application must supply bitmaps in aformat supported by the driver. The application must either store bitmaps in multipleformats or it must be capable of converting a bitmap from one format into another.Either way, dealing with a DDB can be difficult and time consuming.</P><P><A NAME="02"></A><A HREF="02.htm"><B>Figure 15.2.</B></A> <I><BR>A device-dependent bitmap is controlled by the device driver.</I><H3><FONT COLOR="#000077"><B>The DIB Solution</B></FONT></H3><P>To work around these problems, all versions of Windows since the Jurassic era(Windows 3.0) support DIBs. A DIB has a known structure that can be converted easilyinto a DDB whenever necessary. A DIB can exist in two formats: the Windows formatand the OS/2 format. Because the OS/2 format is rarely used, the examples in thishour assume the DIB is in the Windows format. A DIB bitmap stored in a file consistsof four structures, as shown in Figure 15.3.</P><P><A NAME="03"></A><A HREF="03.htm"><B>Figure 15.3.</B></A> <I><BR>DIBs contain four data structures.</I><H3><FONT COLOR="#000077"><B>The <TT>BITMAPFILEHEADER</TT> Structure</B></FONT></H3><P>The <TT>BITMAPFILEHEADER</TT> structure is used only when the bitmap is read orstored to disk. When a DIB is manipulated in memory, the <TT>BITMAPFILEHEADER</TT>structure is often discarded. The remaining parts of the DIB structure follow thesame format whether they're located in memory or in a disk file.<H3><FONT COLOR="#000077"><B>The <TT>BITMAPINFO</TT> Structure</B></FONT></H3><P>The <TT>BITMAPINFO</TT> structure contains a <TT>BITMAPINFOHEADER</TT> and zeroor more palette values for pixels stored in the bitmap. <TT>BITMAPINFOHEADER</TT>contains information about the dimensions, color format, and compression for thebitmap.</P><P>After the <TT>BITMAPINFOHEADER</TT> structure, the <TT>bmiColors</TT> variablemarks the beginning of the color table. This table is used if the bitmap isn't a16-, 24-, or 32-bits-per-pixel bitmap. The color table is an array of <TT>RGBQUAD</TT>structures, with each entry storing one of the colors used by the bitmap. The membersof the <TT>RGBQUAD</TT> structure are</P><PRE><FONT COLOR="#0066FF"><TT>BYTE    rgbBlue;</TT><TT>BYTE    rgbGreen;</TT><TT>BYTE    rgbRed;</TT><TT>BYTE    rgbReserved; // Always set to zero</TT></FONT></PRE><P>The members of the <TT>RGBQUAD</TT> structure represent the red, green, and bluecolor intensity for a color stored in the color table. Each structure member hasa range of 0-255. If all members have a value of 0, the color is black; if all membershave a value of 255, the color is white.<H3><FONT COLOR="#000077"><B>The DIB Image Array</B></FONT></H3><P>An array of pixel information follows the color table. Every pixel in the bitmapis represented by one element of this array. Each element contains a value that representsone of the color map entries. If the first element in the array has a value of 32,the first pixel in the bitmap will use the color found in color table entry number32, as shown in Figure 15.4.</P><P><A NAME="04"></A><A HREF="04.htm"><B>Figure 15.4.</B></A> <I><BR>Every entry in the image array refers to a pixel in the displayed image.</I></P><P>If this is a 16-, 24-, or 32-bits-per-pixel bitmap, there was no color table andeach element of the array contains the RGB color for a single pixel. In effect, thepalette has been moved out to the pixel array for these types of bitmaps.<H3><FONT COLOR="#000077"><B>256-Color DIBs</B></FONT></H3><P>You might think that manipulating a 256-color bitmap is just as easy as loadinga 16-color bitmap using the MFC <TT>CBitmap</TT> class. Unfortunately, that's notthe case. When a 256-color DIB is displayed on a 256-color device, the colors arealmost never correct because of how Windows handles the color palette.<H3><FONT COLOR="#000077"><B>An Overview of the Windows Color Palette</B></FONT></H3><P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>Windows uses <I>color palettes</I>to track the colors that are displayed for a particular window.</P><P>Before examining the C++ class used to display 256-color bitmaps, it's importantto discuss how Windows determines the colors available to your application. Unfortunately,when a bitmap is loaded, Windows makes no special effort to make sure that colorentries in the bitmap's color table are added to the system's color palette. Theresult is an ugly-looking bitmap.<BLOCKQUOTE>	<P><HR><B> </B><FONT COLOR="#000077"><B>Time Saver:</B></FONT><B> </B>To display a 256-color	bitmap, you must always create and manage a logical palette for your application.	<HR></BLOCKQUOTE><P>The Windows GDI uses palettes to manage color selection for 256-color devices.There are actually several different types of palettes, as shown in Figure 15.5.</P><P><A NAME="05"></A><A HREF="05.htm"><B>Figure 15.5.</B> </A><BR><I>The different types of color palettes used in Windows.</I></P><P>Three different types of palettes are shown in Figure 15.5:<UL>	<LI>Device drivers that use palettes have an internal palette that stores the current	set of colors available for display. This means that 256-color devices have 256 entries	in the hardware palette.<BR>	<BR>		<LI>The Windows NT palette maintains a system palette that matches the hardware palette.	When this palette is updated, the operating system will also take the necessary steps	to have the device driver update its internal palette.<BR>	<BR>		<LI>Every application can have one or more logical palettes. An application interacts	with the system palette in order to control the colors that are currently available	for display.</UL><BLOCKQUOTE>	<P><HR><B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>To maintain some	level of consistency, Windows reserves the first 10 and last 10 palette entries for	its own use, leaving 236 palette entries for application use, as shown in Figure	15.6. 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人av免费在线| 国产91色综合久久免费分享| 免费成人在线影院| 国产成人免费在线观看不卡| 91视频.com| 欧美一区二区三区免费视频| 国产亚洲欧美一区在线观看| 亚洲欧美偷拍三级| 日本91福利区| 成人高清视频免费观看| 欧美乱熟臀69xxxxxx| 久久久久久久久99精品| 亚洲一区在线播放| 国产一区二区不卡在线| 欧日韩精品视频| 久久老女人爱爱| 午夜日韩在线电影| 国产精品456| 欧美人与z0zoxxxx视频| 国产女同互慰高潮91漫画| 亚洲不卡一区二区三区| 国产成人aaa| 7777精品伊人久久久大香线蕉超级流畅 | 色综合欧美在线| 日韩午夜在线观看视频| 日韩一区在线看| 久久丁香综合五月国产三级网站| 成人va在线观看| 日韩视频免费观看高清完整版在线观看 | 亚洲美女屁股眼交3| 久久成人精品无人区| 91猫先生在线| 久久久欧美精品sm网站| 午夜免费欧美电影| 成人免费视频国产在线观看| 欧美精品日韩精品| 中文字幕视频一区二区三区久| 精品一区二区三区欧美| 欧美日韩在线三级| 国产精品久99| 国产一区二区主播在线| 欧美女孩性生活视频| 中文字幕综合网| 国产成人在线免费| 欧美变态tickle挠乳网站| 亚洲午夜免费电影| 91在线观看一区二区| 精品国产91乱码一区二区三区 | 一本久道中文字幕精品亚洲嫩| 久久嫩草精品久久久精品| 免费在线观看一区二区三区| 91在线观看成人| 国产精品高清亚洲| 国产成人精品免费一区二区| 日韩一区二区三区四区五区六区| 亚洲综合丝袜美腿| 一本一道综合狠狠老| 国产精品久久毛片av大全日韩| 国产一区在线观看视频| 日韩美一区二区三区| 麻豆一区二区三| 欧美一区在线视频| 日本成人在线网站| 91精品久久久久久蜜臀| 亚洲第一福利一区| 欧美三级三级三级爽爽爽| 亚洲综合999| 欧美日韩国产在线播放网站| 亚洲一区二区在线视频| 欧美亚洲国产一卡| 亚洲图片欧美综合| 欧美日韩一区二区不卡| 五月激情综合网| 91精品国产色综合久久不卡蜜臀 | 日韩一级大片在线观看| 日本欧美一区二区三区乱码| 4438成人网| 美女性感视频久久| 精品久久久久久久久久久久包黑料 | 97精品电影院| 亚洲视频 欧洲视频| 91丝袜国产在线播放| 亚洲乱码中文字幕综合| 欧美亚洲日本国产| 午夜av区久久| 日韩视频在线一区二区| 精品亚洲欧美一区| 精品福利一区二区三区免费视频| 国产在线麻豆精品观看| 国产亚洲欧美日韩日本| 成人18视频日本| 亚洲午夜一区二区| 制服丝袜成人动漫| 极品少妇一区二区三区精品视频| 久久这里都是精品| 成人av手机在线观看| 一区二区三区国产| 3d动漫精品啪啪| 国产成人午夜精品影院观看视频| 中文字幕欧美一区| 欧美日韩中文字幕精品| 蜜桃精品在线观看| 欧美国产激情一区二区三区蜜月| 99久久免费精品高清特色大片| 亚洲国产日韩在线一区模特| 91精品国产福利| 国产精品中文字幕一区二区三区| 亚洲婷婷在线视频| 欧美婷婷六月丁香综合色| 免费日韩伦理电影| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 一区二区三区不卡在线观看| 88在线观看91蜜桃国自产| 国产一区二区日韩精品| 亚洲视频一二区| 日韩美女在线视频| 99久久国产综合精品女不卡| 婷婷久久综合九色国产成人| 久久伊人蜜桃av一区二区| 不卡的av在线播放| 日日摸夜夜添夜夜添国产精品| 精品日韩在线观看| 色狠狠桃花综合| 精品一区二区三区不卡| 一区二区三区在线免费播放| 日韩欧美精品三级| 色婷婷激情久久| 国产一区二区在线免费观看| 亚洲欧美日韩一区二区| 欧美tickling网站挠脚心| 日本韩国一区二区| 国产精品一区不卡| 午夜精品福利在线| 国产精品毛片大码女人| 日韩欧美中文一区| 在线视频一区二区三| 国产xxx精品视频大全| 午夜视频一区在线观看| 国产精品久久99| 精品国产髙清在线看国产毛片| 欧美性视频一区二区三区| 国产白丝网站精品污在线入口| 日韩成人伦理电影在线观看| 成人欧美一区二区三区视频网页 | 免费成人深夜小野草| 亚洲精品大片www| 国产精品视频第一区| 欧美成人高清电影在线| 欧美午夜不卡在线观看免费| 不卡的电影网站| 国产伦精品一区二区三区免费| 午夜精品久久久久久久久| 国产精品久久久久久久蜜臀 | 国产精品一区二区91| 五月婷婷综合在线| 亚洲激情六月丁香| 国产精品成人一区二区三区夜夜夜| 精品国产一区二区三区不卡| 欧美欧美欧美欧美首页| 在线视频综合导航| 色诱亚洲精品久久久久久| 丁香天五香天堂综合| 国产在线视视频有精品| 久久精品国产久精国产| 日本网站在线观看一区二区三区| 一区二区三区中文在线观看| 中文字幕一区二区三区精华液| 久久久久免费观看| 欧美精品一区二区三区四区| 91精品国产综合久久久久久漫画| 欧美中文字幕不卡| 欧美在线免费视屏| 色欧美片视频在线观看 | 亚洲成人综合在线| 亚洲激情男女视频| 一区二区三区欧美日韩| 亚洲蜜臀av乱码久久精品蜜桃| 国产精品色婷婷| 日本一区二区不卡视频| 中文子幕无线码一区tr| 久久久精品天堂| 国产日韩欧美综合一区| 国产亚洲一区字幕| 国产欧美精品一区二区三区四区| 久久欧美一区二区| 国产色爱av资源综合区| 国产精品久久看| 亚洲人成7777| 伊人色综合久久天天人手人婷| 亚洲精品欧美专区| 亚洲综合激情另类小说区| 亚洲最大成人综合| 午夜av一区二区| 久久成人av少妇免费| 狠狠色狠狠色合久久伊人| 国产精一品亚洲二区在线视频| 国产成a人无v码亚洲福利| 99久久精品一区二区| 在线一区二区三区四区五区| 欧美三区在线观看|