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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch15.htm

?? 24小時精通VC
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<HR></BLOCKQUOTE><P><A NAME="06"></A><A HREF="06.htm"><B>Figure 15.6.</B></A> <I><BR>Windows makes 236 palette entries available to applications.</I><BLOCKQUOTE>	<P><HR><B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>At first glance,	it might seem unfair for 20 entries to be removed from the system palette. These	entries are removed to keep the basic window display predictable. The 20 reserved	palette entries include the colors used by 16-color VGA devices. As long as these	palette entries are available, Windows applications that don't use the palette are	displayed as expected. <HR></BLOCKQUOTE><H3><FONT COLOR="#000077"><B>The System Palette</B></FONT></H3><P>A palette is one of the attributes that belong to a DC. After you have decidedto use a palette in your application, you must follow these basic steps:<DL>	<DD>1. Create a logical palette. This is the process of allocating space for the	palette entries and describing the colors that will be included in the palette. As	you'll learn, this process is much easier than it sounds. In most cases, when you	must create a palette you copy the colors from a bitmap or other object into the	new palette. This step is usually performed once, and the logical palette is stored	by the application so that it can be used whenever needed.<BR>	<BR>	2. Select the palette into a DC. Unlike other GDI objects, <TT>SelectObject</TT>	doesn't work for logical palettes. You must use the <TT>SelectPalette</TT> function.<BR>	<BR>	3. Realize the palette. Basically, realizing the palette asks the Windows Palette	Manager to add your palette to the system palette or map your palette to a reasonably	close substitute. Selecting and realizing the palette always happens at the same	time; there's no point in selecting a palette unless you intend to realize it immediately.<BR>	<BR>	4. Use the palette. If the system palette was updated, the application should redraw	itself. This is usually done by invalidating any windows that depend on palette entries.<BR>	<BR>	5. Deselect the palette by selecting the previous palette back into the DC.<BR>	<BR>	6. Delete the palette object. This step is usually performed only when you're sure	the palette is no longer needed.</DL><P>Two messages related to palettes are sent to your application:<UL>	<LI>When a window moves into the foreground, Windows sends it a <TT>WM_QUERYNEWPALETTTE</TT>	message. In response to this message, your application should realize its palette.<BR>	<BR>		<LI>If the system palette is changed, all windows in the background receive a <TT>WM_PALETTECHANGED</TT>	message. An application in the background should realize its palette to attempt to	reassert colors in the system palette. If no free positions in the system palette	are available, the Palette Manager maps the requested color to the closest palette	entry.</UL><P>In any case, you should invalidate any parts of your application that depend onyour logical palette if the system palette is updated.<H2><FONT COLOR="#000077"><B>The Dib Example</B></FONT></H2><P>As an example of how 256-color bitmaps are displayed, you will now create an MFCexample named Dib. The design of the Dib project uses a basic AppWizard SDI skeletonwith these modifications:<UL>	<LI>A reusable class that handles the display of DIBs, <TT>CDIBitmap</TT><BR>	<BR>		<LI>A reusable class that handles the creation of a new 256-color palette, <TT>CBmpPalette</TT><BR>	<BR>		<LI>Additional palette message-handling functions</UL><H3><FONT COLOR="#000077"><B>The <TT>CDIBitmap</TT> Class</B></FONT></H3><P>The <TT>CDIBitmap</TT> class does most of the work in the Dib project. The <TT>CDIBitmap</TT>class provides an easy-to-use interface for handling 256-color DIBs. The class interfacefor <TT>CDIBitmap</TT> is shown in Listing 15.2. Save this file as <TT>dib256.h</TT>.<H4><FONT COLOR="#000077">TYPE: Listing 15.2. The CDIBitmap class interface.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>#ifndef DIBMP_TYS</TT><TT>#define DIBMP_TYS</TT><TT>class CDIBitmap</TT><TT>{</TT><TT>    friend class CBmpPalette;</TT><TT>//constructors</TT><TT>public:</TT><TT>    CDIBitmap();</TT><TT>    virtual ~CDIBitmap();</TT><TT>private:</TT><TT>    CDIBitmap( const CDIBitmap&amp; dbmp ){};</TT><TT>//operations</TT><TT>public:</TT><TT>    inline BITMAPINFO* GetHeaderPtr();</TT><TT>    inline BYTE* GetPixelPtr();</TT><TT>    virtual void DrawDIB ( CDC* pDC, int x, int y );</TT><TT>    virtual BOOL Load( CFile* pFile );</TT><TT>    RGBQUAD* GetColorTablePtr();</TT><TT>protected:</TT><TT>    int GetPalEntries() const;</TT><TT>    int GetPalEntries( BITMAPINFOHEADER&amp; infoHeader ) const;</TT><TT>protected:</TT><TT>    int GetWidth() const;</TT><TT>    int GetHeight() const;</TT><TT>//implementation</TT><TT>private:</TT><TT>    BITMAPINFO* m_pInfo;</TT><TT>    BYTE*               m_pPixels;</TT><TT>};</TT><TT>#endif</TT></FONT></PRE><P>Note that <TT>CDIBitmap</TT> isn't derived from <TT>CBitmap</TT>, or <TT>CObject</TT>for that matter. The class itself consumes only a few bytes, requiring space fortwo pointers and a virtual function table. <TT>CDIBitmap</TT> has five public functions:<UL>	<LI><TT>GetHeaderPtr</TT>: Returns a pointer to the <TT>BITMAPINFO</TT> structure.<BR>	<BR>		<LI><TT>GetPixelPtr</TT>: Returns a pointer to the beginning of the pixel image array.<BR>	<BR>		<LI><TT>DrawDIB</TT>: Draws the DIB at a specified location.<BR>	<BR>		<LI><TT>Load</TT>: Reads a DIB from a <TT>.BMP</TT> file and initializes the <TT>CDIBitmap</TT>	object.<BR>	<BR>		<LI><TT>GetColorTablePtr</TT>: Returns a pointer to the color table.</UL><P>The source code for the implementation of <TT>CDIBitmap</TT> is provided in Listing15.3. Save this file as <TT>dib256.cpp</TT>, and add it to the Dib project.<H4><FONT COLOR="#000077">TYPE: Listing 15.3. The implementation of the CDIBitmapclass.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>#include &quot;stdafx.h&quot;</TT><TT>#include &quot;dib256.h&quot;</TT><TT>CDIBitmap::CDIBitmap()</TT><TT>{</TT><TT>    m_pInfo = 0;</TT><TT>    m_pPixels = 0;</TT><TT>}</TT><TT>CDIBitmap::~CDIBitmap()</TT><TT>{</TT><TT>    delete [] (BYTE*)m_pInfo;</TT><TT>    delete [] m_pPixels;</TT><TT>}</TT><TT>BOOL CDIBitmap::Load( CFile* pFile )</TT><TT>{</TT><TT>    ASSERT( pFile );</TT><TT>    BOOL fReturn = TRUE;</TT><TT>    delete [] (BYTE*)m_pInfo;</TT><TT>    delete [] m_pPixels;</TT><TT>    m_pInfo = 0;</TT><TT>    m_pPixels = 0;</TT><TT>    DWORD       dwStart = pFile-&gt;GetPosition();</TT><TT>    // Check to make sure we have a bitmap. The first two bytes must</TT><TT>    // be `B' and `M'.</TT><TT>    BITMAPFILEHEADER fileHeader;</TT><TT>    pFile-&gt;Read(&amp;fileHeader, sizeof(fileHeader));</TT><TT>    if( fileHeader.bfType != 0x4D42 )</TT><TT>        return FALSE;</TT><TT>    BITMAPINFOHEADER infoHeader;</TT><TT>    pFile-&gt;Read( &amp;infoHeader, sizeof(infoHeader) );</TT><TT>    if( infoHeader.biSize != sizeof(infoHeader) )</TT><TT>        return FALSE;</TT><TT>    // Store the sizes of the DIB structures</TT><TT>    int cPaletteEntries = GetPalEntries( infoHeader );</TT><TT>    int cColorTable = 256 * sizeof(RGBQUAD);</TT><TT>    int cInfo = sizeof(BITMAPINFOHEADER) + cColorTable;</TT><TT>    int cPixels = fileHeader.bfSize - fileHeader.bfOffBits;</TT><TT>    // Allocate space for a new bitmap info header, and copy</TT><TT>    // the info header that was loaded from the file. Read the</TT><TT>    // the file and store the results in the color table.</TT><TT>    m_pInfo = (BITMAPINFO*)new BYTE[cInfo];</TT><TT>    memcpy( m_pInfo, &amp;infoHeader, sizeof(BITMAPINFOHEADER) );</TT><TT>    pFile-&gt;Read( ((BYTE*)m_pInfo) + sizeof(BITMAPINFOHEADER),</TT><TT>                 cColorTable );</TT><TT>    //</TT><TT>    // Allocate space for the pixel area, and load the pixel</TT><TT>    // info from the file.</TT><TT>    m_pPixels = new BYTE[cPixels];</TT><TT>    pFile-&gt;Seek(dwStart + fileHeader.bfOffBits, CFile::begin);</TT><TT>    pFile-&gt;Read( m_pPixels, cPixels );</TT><TT>    return fReturn;</TT><TT>}</TT><TT>// DrawDib uses StretchDIBits to display the bitmap.</TT><TT>void CDIBitmap::DrawDIB( CDC* pDC, int x, int y )</TT><TT>{</TT><TT>    HDC     hdc = pDC-&gt;GetSafeHdc();</TT><TT>    if( m_pInfo )</TT><TT>        StretchDIBits( hdc, x, y,</TT><TT>                       GetWidth(),</TT><TT>                       GetHeight(),</TT><TT>                       0, 0,</TT><TT>                       GetWidth(),</TT><TT>                       GetHeight(),</TT><TT>                       GetPixelPtr(),</TT><TT>                       GetHeaderPtr(),</TT><TT>                       DIB_RGB_COLORS,</TT><TT>                       SRCCOPY );</TT><TT>}</TT><TT>BITMAPINFO* CDIBitmap::GetHeaderPtr()</TT><TT>{</TT><TT>    return m_pInfo;</TT><TT>}</TT><TT>RGBQUAD* CDIBitmap::GetColorTablePtr()</TT><TT>{</TT><TT>    RGBQUAD* pColorTable = 0;</TT><TT>    if( m_pInfo != 0 )</TT><TT>    {</TT><TT>        int cOffset = sizeof(BITMAPINFOHEADER);</TT><TT>        pColorTable = (RGBQUAD*)(((BYTE*)(m_pInfo)) + cOffset);</TT><TT>    }</TT><TT>    return pColorTable;</TT><TT>}</TT><TT>BYTE* CDIBitmap::GetPixelPtr()</TT><TT>{</TT><TT>    return m_pPixels;</TT><TT>}</TT><TT>int CDIBitmap::GetWidth() const</TT><TT>{</TT><TT>    return m_pInfo-&gt;bmiHeader.biWidth;</TT><TT>}</TT><TT>int CDIBitmap::GetHeight() const</TT><TT>{</TT><TT>    return m_pInfo-&gt;bmiHeader.biHeight;</TT><TT>}</TT><TT>int CDIBitmap::GetPalEntries() const</TT><TT>{</TT><TT>    return GetPalEntries( *(BITMAPINFOHEADER*)m_pInfo );</TT><TT>}</TT><TT>int CDIBitmap::GetPalEntries( BITMAPINFOHEADER&amp; infoHeader ) const</TT><TT>{</TT><TT>    int nReturn;</TT><TT>    if( infoHeader.biClrUsed == 0 )</TT><TT>    {</TT><TT>        nReturn = ( 1 &lt;&lt; infoHeader.biBitCount );</TT><TT>    }</TT><TT>    else</TT><TT>        nReturn = infoHeader.biClrUsed;</TT><TT>    return nReturn;</TT><TT>}</TT></FONT></PRE><P>Most of the work in the <TT>CDIBitmap</TT> class is done by the <TT>CDIBitmap::Load</TT>member function. This member function takes a pointer to an MFC <TT>CFile</TT> objectas its only parameter. Later in this hour, you will see how the sample program providesa <TT>CFile</TT> pointer to this function during serialization.</P><P>After verifying that the <TT>CFile</TT> object refers to a Windows bitmap, the<TT>Load</TT> function reads each part of the bitmap data structure and creates aDIB dynamically. Note that there actually are two calls to the new operator; thereis no requirement that the DIB exist in one solid chunk of memory. The <TT>BITMAPINFOHEADER</TT>is stored in one location, and the pixel image array is stored in another location.</P><P>The <TT>CDIBitmap::DrawDIB</TT> member function calls <TT>StretchDIBits</TT> todisplay the DIB. Very little work is actually done in this function. For example,the width and height of the DIB are calculated using <TT>CDIBitmap</TT> member functions.</P><P>The remaining member functions are used to calculate various bits of informationabout the DIB. Only a pointer to the beginning of the <TT>BITMAPINFO</TT> structureand a pointer to the beginning of the pixel image array are stored; all other informationis calculated as it is needed.<H3><FONT COLOR="#000077"><B>The <TT>CBmpPalette</TT> Class</B></FONT></H3><P>You use the <TT>CBmpPalette</TT> class to create a logical palette that containsthe colors used by a <TT>CDIBitmap</TT> object. Although the MFC class library includesa <TT>CPalette</TT> class, you must derive your own class from it in order to doany meaningful work. Listing 15.4 contains the declaration for <TT>CBmpPalette</TT>.Save this file as <TT>dibpal.h</TT>.<H4><FONT COLOR="#000077">TYPE: Listing 15.4. The CBmpPalette class interface.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>#ifndef BMP_PAL_TYS</TT><TT>#define BMP_PAL_TYS</TT><TT>class CBmpPalette : public CPalette</TT><TT>{</TT><TT>public:</TT><TT>    CBmpPalette( CDIBitmap* pBmp );</TT><TT>};</TT><TT>#endif</TT></FONT></PRE><P>All the work done by <TT>CBmpPalette</TT> is done in the constructor; there areno member functions other than the function inherited from <TT>CPalette</TT>, theMFC base class. The <TT>CBmpPalette</TT> class is always used with <TT>CDIBitmap</TT>.A pointer to a <TT>CDIBitmap</TT> object is passed to <TT>CBmpPalette</TT> as a constructorparameter.</P><P><TT>CBmpPalette</TT> allocates a logical palette with enough entries to storethe palette required by the <TT>CDIBitmap</TT> object. After storing some basic paletteinformation, the palette entries are filled in, using the values collected from the<TT>CDIBitmap</TT> object. After the palette is created, the logical palette is deleted.The implementation from <TT>CBmpPalette</TT> is provided in Listing 15.5 and is includedin the Dib project as <TT>dibpal.cpp</TT>.<H4><FONT COLOR="#000077">TYPE: Listing 15.5. The implementation of the CBmpPaletteclass.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>#include &quot;stdafx.h&quot;</TT><TT>#include &quot;dib256.h&quot;</TT><TT>#include &quot;dibpal.h&quot;</TT><TT>CBmpPalette::CBmpPalette( CDIBitmap* pBmp )</TT><TT>{</TT><TT>    ASSERT( pBmp );</TT><TT>    int cPaletteEntries = pBmp-&gt;GetPalEntries();</TT><TT>    int cPalette = sizeof(LOGPALETTE) +</TT><TT>                   sizeof(PALETTEENTRY) * cPaletteEntries;</TT><TT>    // Since the LOGPALETTE structure is open-ended, you</TT><TT>    // must dynamically allocate it.</TT><TT>    LOGPALETTE* pPal = (LOGPALETTE*)new BYTE[cPalette];</TT><TT>    RGBQUAD*    pColorTab = pBmp-&gt;GetColorTablePtr();</TT><TT>    pPal-&gt;palVersion = 0x300;</TT>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人激情开心网| 亚洲国产精品一区二区久久| 激情亚洲综合在线| 精品久久久久久亚洲综合网| 激情都市一区二区| 日本一区二区三区四区在线视频| 国产一区二区三区综合| 亚洲国产高清在线| 色综合天天综合网天天狠天天 | 亚洲精品高清在线观看| 亚洲欧美日韩国产手机在线| 国产精品毛片高清在线完整版| 久久久青草青青国产亚洲免观| 国产午夜亚洲精品羞羞网站| 国产曰批免费观看久久久| 国产精品久久久久毛片软件| 91精品国产全国免费观看| 五月婷婷欧美视频| 成人在线综合网站| 91美女视频网站| 精品福利一区二区三区免费视频| 免费精品视频最新在线| 国产亚洲综合在线| 日韩国产欧美在线播放| 天堂午夜影视日韩欧美一区二区| 精品三级在线看| 精品久久久久久久久久久久久久久久久| 成人综合婷婷国产精品久久| 国产日韩综合av| 一卡二卡欧美日韩| 精品在线观看视频| 日韩欧美一二三| 亚洲第一激情av| 99久久国产综合精品色伊| 亚洲视频图片小说| 91麻豆精东视频| 国产日韩欧美在线一区| 一区二区三区电影在线播| 日韩在线卡一卡二| 日本精品一级二级| 日韩女优av电影在线观看| 亚洲国产精华液网站w| 亚洲福利电影网| 91九色02白丝porn| 精品国产自在久精品国产| 欧美一区二区三区影视| 欧美tickling网站挠脚心| 亚洲欧美另类图片小说| 美女国产一区二区| 成人黄色大片在线观看| 精品国产精品一区二区夜夜嗨| 国产精品丝袜久久久久久app| 亚洲电影视频在线| 国产成人午夜电影网| 精品久久久久久久久久久久包黑料| 亚洲理论在线观看| 99re这里只有精品首页| 欧美r级电影在线观看| 狠狠网亚洲精品| 国产日韩欧美精品综合| 国产拍欧美日韩视频二区| 男女男精品网站| 亚洲精品乱码久久久久久| 国产精品女同互慰在线看| 精品日韩欧美在线| 69堂成人精品免费视频| 欧美午夜精品久久久久久超碰| 成人h动漫精品一区二| 国产成人综合精品三级| 黄页视频在线91| 精品一区二区在线观看| 韩国成人福利片在线播放| 美腿丝袜亚洲综合| 伦理电影国产精品| 麻豆传媒一区二区三区| 免费在线观看精品| 久草在线在线精品观看| 精品亚洲免费视频| 国产在线播放一区三区四| 国产一区二区不卡老阿姨| 韩国欧美国产一区| 国产乱妇无码大片在线观看| 国产一区999| 国产美女一区二区| 成人丝袜高跟foot| 91亚洲精华国产精华精华液| 色综合欧美在线| 欧美在线啊v一区| 欧美精品v国产精品v日韩精品| 制服丝袜av成人在线看| 亚洲精品在线观看网站| 国产日韩欧美亚洲| 亚洲色图欧美偷拍| 亚洲国产成人porn| 日本不卡一区二区三区| 久久精品国内一区二区三区| 国产一区二区三区综合| 成人sese在线| 欧美人与性动xxxx| 久久久久久一二三区| 国产精品日韩精品欧美在线| 亚洲精品国产一区二区三区四区在线| 亚洲国产综合人成综合网站| 奇米色一区二区| 豆国产96在线|亚洲| 91国产成人在线| 91精品欧美一区二区三区综合在 | 91久久精品国产91性色tv| 欧美亚洲图片小说| 精品日韩在线观看| 最新国产成人在线观看| 日本亚洲视频在线| 粉嫩蜜臀av国产精品网站| 欧美日韩亚洲综合| 久久久噜噜噜久久中文字幕色伊伊 | 一区二区三区四区高清精品免费观看 | 成人国产视频在线观看| 欧美日韩小视频| 欧美国产日本韩| 丝袜亚洲精品中文字幕一区| 福利91精品一区二区三区| 欧美日韩一区三区| 欧美激情一区二区三区在线| 亚洲大片在线观看| 国产91高潮流白浆在线麻豆 | 久久99这里只有精品| 99精品热视频| 精品国产一区二区亚洲人成毛片| 1024国产精品| 国产精品综合av一区二区国产馆| 在线观看视频一区二区欧美日韩| 精品国产露脸精彩对白| 亚洲电影一区二区| 99精品在线观看视频| 精品久久久久av影院| 亚洲va欧美va天堂v国产综合| 成人综合在线视频| 欧美电影免费提供在线观看| 亚洲高清免费观看高清完整版在线观看| 国产一区二区三区蝌蚪| 欧美一区二区三区日韩视频| 亚洲精品老司机| a亚洲天堂av| 亚洲国产成人在线| 久久精品国产一区二区三区免费看| 欧洲激情一区二区| 亚洲欧洲日韩女同| 东方欧美亚洲色图在线| 精品奇米国产一区二区三区| 偷拍一区二区三区四区| 91国偷自产一区二区三区观看| 国产精品入口麻豆原神| 国产99久久久国产精品| 精品美女在线观看| 秋霞午夜鲁丝一区二区老狼| 欧美乱熟臀69xxxxxx| 樱花影视一区二区| 91网上在线视频| 国产精品国产精品国产专区不蜜 | 美洲天堂一区二卡三卡四卡视频| 欧美日韩精品一二三区| 亚洲国产视频a| 色婷婷亚洲综合| 亚洲色图制服丝袜| 色美美综合视频| 亚洲激情网站免费观看| 99re这里都是精品| 亚洲男人都懂的| 色素色在线综合| 亚洲综合成人网| 欧美麻豆精品久久久久久| 亚洲综合偷拍欧美一区色| 日本福利一区二区| 亚洲一区二区三区在线播放| 日本乱人伦aⅴ精品| 亚洲综合色婷婷| 欧美日本国产一区| 偷偷要91色婷婷| 精品国产免费一区二区三区四区| 麻豆精品一区二区综合av| 精品美女一区二区三区| 经典三级在线一区| 国产日产欧美精品一区二区三区| 成人黄色网址在线观看| 亚洲久草在线视频| 日本高清免费不卡视频| 丝袜国产日韩另类美女| 日韩一二在线观看| 国产一区二区不卡老阿姨| 国产精品国产精品国产专区不片| 91视频免费播放| 日韩中文字幕区一区有砖一区| 日韩一本二本av| 国产美女一区二区三区| 中文字幕精品一区| 欧美私人免费视频| 激情六月婷婷综合| 亚洲欧美福利一区二区| 777a∨成人精品桃花网| 国产一区二区三区精品视频|