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

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

?? ch15.htm

?? 一天之內(nèi)學(xué)會(huì)VC#. 主要介紹VC#的各種應(yīng)用和示例
?? HTM
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
<!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. 

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产三级国产专播品爱网 | 日韩影视精彩在线| 久久久亚洲国产美女国产盗摄 | 国产成人av福利| 亚洲自拍偷拍麻豆| 中文字幕精品一区二区精品绿巨人 | 国产亚洲欧洲997久久综合 | 欧美一级片免费看| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 天天操天天综合网| 《视频一区视频二区| 精品成人一区二区| 欧美群妇大交群的观看方式| 91丨九色丨黑人外教| 国产美女精品人人做人人爽| 日韩成人午夜精品| 亚洲一二三四区不卡| 亚洲色图视频免费播放| 国产亚洲成av人在线观看导航| 9191久久久久久久久久久| 在线亚洲+欧美+日本专区| av资源网一区| 成人免费高清在线观看| 国产一区二区调教| 久久精品国产色蜜蜜麻豆| 天堂一区二区在线免费观看| 亚洲综合一二区| 亚洲精品中文在线| 亚洲欧美一区二区三区孕妇| 欧美激情艳妇裸体舞| 久久精品欧美日韩| 国产视频911| 国产色综合一区| 国产欧美日韩麻豆91| 国产日韩欧美a| 久久精品无码一区二区三区| 久久精品人人做人人爽97| 久久久久久久电影| 国产精品色哟哟| 中文字幕制服丝袜成人av| 国产精品的网站| 日韩理论电影院| 一区二区中文字幕在线| 亚洲少妇中出一区| 亚洲综合色噜噜狠狠| 午夜久久久久久久久久一区二区| 午夜久久久久久久久久一区二区| 日韩av一区二| 久久国产人妖系列| 国产精品69久久久久水密桃| 国产成人免费视频| 91蜜桃在线免费视频| 91豆麻精品91久久久久久| 欧美色男人天堂| 欧美一二三区精品| 国产亚洲污的网站| 亚洲少妇屁股交4| 亚洲电影在线播放| 麻豆国产精品777777在线| 国产乱色国产精品免费视频| 床上的激情91.| 欧美怡红院视频| 日韩一区二区三区免费观看| 久久午夜电影网| 亚洲欧洲日韩综合一区二区| 亚洲小说春色综合另类电影| 蜜臀av一级做a爰片久久| 国产.精品.日韩.另类.中文.在线.播放| 成人夜色视频网站在线观看| 欧美性淫爽ww久久久久无| 日韩欧美一级二级| 国产精品国产a级| 亚洲第一二三四区| 国产精品影音先锋| 一本在线高清不卡dvd| 日韩亚洲欧美在线| 国产精品久久久久影院色老大| 亚洲国产精品视频| 国产精品888| 欧洲精品一区二区三区在线观看| 欧美v国产在线一区二区三区| 国产精品乱码一区二区三区软件 | 国产欧美一区二区精品久导航| 一区视频在线播放| 老鸭窝一区二区久久精品| 成人高清av在线| 日韩视频免费观看高清完整版在线观看| 久久久久国产精品麻豆| 亚洲成人免费影院| 不卡av电影在线播放| 在线成人免费观看| 最近日韩中文字幕| 久久精品久久综合| 欧美在线一区二区三区| 国产精品女同互慰在线看| 日韩中文字幕一区二区三区| 99精品欧美一区二区蜜桃免费| 欧美一区二区视频在线观看 | 亚洲国产成人高清精品| 成人性生交大合| 精品国产青草久久久久福利| 一区二区三区在线观看国产| 高清不卡一区二区| 日韩女优视频免费观看| 亚洲一区视频在线观看视频| 高清av一区二区| 久久综合色之久久综合| 日日噜噜夜夜狠狠视频欧美人| 91丨九色丨蝌蚪丨老版| 国产喷白浆一区二区三区| 精品一区二区免费看| 欧美精品一卡二卡| 亚洲无人区一区| 色999日韩国产欧美一区二区| 日本一区二区三级电影在线观看| 美女视频一区二区三区| 欧美日韩免费观看一区二区三区| 成人免费在线播放视频| 成人av影视在线观看| 国产欧美一区二区精品婷婷| 国产做a爰片久久毛片| 日韩免费福利电影在线观看| 欧美aaaaa成人免费观看视频| 欧美裸体bbwbbwbbw| 亚洲成人你懂的| 欧美亚洲动漫精品| 亚洲国产精品久久人人爱| 色88888久久久久久影院野外| 综合欧美亚洲日本| 91网站在线播放| 亚洲精品久久7777| 91国模大尺度私拍在线视频 | 国产精品99久久久久久久vr| 91精品国产91久久综合桃花| 日韩成人免费看| 日韩一区二区影院| 久久电影网站中文字幕| 精品国产成人系列| 国产资源在线一区| 中文字幕乱码一区二区免费| 成人免费视频一区| 中文字幕综合网| 91精品福利在线| 亚洲国产日韩在线一区模特| 欧美日韩国产一二三| 天天影视色香欲综合网老头| 欧美高清激情brazzers| 免费一级片91| 久久综合久久鬼色| 成人精品鲁一区一区二区| 综合中文字幕亚洲| 欧美午夜片在线看| 另类中文字幕网| 国产精品免费丝袜| 色av成人天堂桃色av| 日韩av一区二区三区四区| 久久久综合网站| 色综合夜色一区| 午夜不卡av在线| 欧美精品一区二区三区高清aⅴ| 丁香啪啪综合成人亚洲小说| 亚洲欧美日韩人成在线播放| 欧美日本不卡视频| 国产精品亚洲一区二区三区妖精| 国产精品日韩成人| 欧美日韩精品欧美日韩精品一 | 精品一区二区三区香蕉蜜桃| 国产日韩精品视频一区| 91色婷婷久久久久合中文| 性久久久久久久久| 久久精品人人做人人爽人人 | 国产欧美精品区一区二区三区| www.66久久| 天天综合色天天综合色h| 国产亚洲精品bt天堂精选| 欧美在线一区二区| 国产一区二区三区日韩| 伊人色综合久久天天| 欧美一区二区三区视频免费播放 | 久久66热偷产精品| 中文字幕一区av| 欧美一区二区三区四区高清| 成人国产精品视频| 男女男精品视频网| 自拍偷拍国产精品| 2021久久国产精品不只是精品| 99精品欧美一区二区三区综合在线| 日本aⅴ免费视频一区二区三区| 国产精品久久久久久久久免费桃花 | 99riav一区二区三区| 日本sm残虐另类| 亚洲精品成人精品456| 久久久亚洲精品石原莉奈| 欧美久久久久中文字幕| 成人精品高清在线| 韩国成人精品a∨在线观看| 亚洲最快最全在线视频| 国产欧美日韩视频一区二区| 91精品国产乱| 欧美日韩在线免费视频|