亚洲欧美第一页_禁久久精品乱码_粉嫩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高清视频免费看| 首页国产欧美久久| 亚洲女爱视频在线| 亚洲天堂福利av| 一区二区三区四区在线播放| 国产精品福利在线播放| 国产女人18水真多18精品一级做| 日韩欧美一区在线| 精品国产一区二区精华| 欧美变态tickling挠脚心| 精品国产髙清在线看国产毛片| 日韩视频一区二区| 久久精品亚洲麻豆av一区二区| 国产亚洲成av人在线观看导航| 国产亚洲精品免费| 亚洲久草在线视频| 午夜a成v人精品| 国产一区三区三区| 成人91在线观看| 在线观看视频一区二区欧美日韩| 欧美日韩一卡二卡| 久久久综合网站| 亚洲视频小说图片| 日韩av一区二区三区| 国产美女精品人人做人人爽| 成人av在线观| 欧美一区国产二区| 国产三级精品视频| 亚洲欧美区自拍先锋| 日韩高清在线观看| 成人免费视频国产在线观看| 欧美性高清videossexo| 精品久久久久久久久久久久久久久| 久久毛片高清国产| 亚洲国产日韩综合久久精品| 韩国精品主播一区二区在线观看| 成人激情动漫在线观看| 欧美一区二区视频观看视频| 亚洲国产精品黑人久久久| 亚洲成人免费av| 不卡一区二区在线| 日韩精品在线网站| 一区二区在线观看av| 韩国视频一区二区| 欧美日韩国产一区| 综合久久国产九一剧情麻豆| 日日摸夜夜添夜夜添亚洲女人| 成人一级片在线观看| 日韩欧美资源站| 亚洲一区二区av在线| 粉嫩av一区二区三区在线播放| 欧美亚一区二区| 国产精品麻豆欧美日韩ww| 精品在线播放午夜| 欧美日韩一二区| 亚洲美女精品一区| 成人激情校园春色| 2020国产精品久久精品美国| 亚洲无人区一区| aaa欧美色吧激情视频| 日韩一区二区在线观看视频| 亚洲一线二线三线视频| eeuss鲁一区二区三区| 久久久九九九九| 久久国产精品色| 日韩女同互慰一区二区| 香港成人在线视频| 欧美性欧美巨大黑白大战| 国产精品护士白丝一区av| 国产福利一区在线观看| 精品国产一区二区国模嫣然| 蜜臀a∨国产成人精品| 欧美一区二区在线观看| 免费成人av在线| 91麻豆精品国产自产在线观看一区| 亚洲成人在线观看视频| 欧美视频一区在线| 日韩福利电影在线| 欧美一级艳片视频免费观看| 午夜欧美一区二区三区在线播放| 欧美日韩一区 二区 三区 久久精品| 亚洲精品国产品国语在线app| 99久久综合色| 伊人性伊人情综合网| 91国产免费看| 亚洲一二三级电影| 欧美日韩国产精品自在自线| 天天影视网天天综合色在线播放| 欧美性猛交一区二区三区精品| 亚洲福利视频导航| 日韩一区二区免费电影| 国产精品一二二区| 亚洲日本在线天堂| 91精品国产综合久久香蕉的特点 | 99精品欧美一区二区蜜桃免费| 国产喂奶挤奶一区二区三区| 播五月开心婷婷综合| 亚洲电影在线免费观看| 日韩欧美电影在线| 成人免费毛片app| 亚洲在线免费播放| 精品成人一区二区三区| 成人激情免费视频| 天堂成人国产精品一区| 久久精品水蜜桃av综合天堂| 97精品久久久久中文字幕| 亚洲国产精品久久人人爱| 精品国产91久久久久久久妲己| 国产91清纯白嫩初高中在线观看| 尤物视频一区二区| 精品国产一区a| 在线视频你懂得一区| 麻豆精品在线观看| 亚洲视频 欧洲视频| 精品剧情在线观看| 色综合久久天天综合网| 国内精品视频666| 一区二区三区自拍| 久久久久久一二三区| 欧美性xxxxx极品少妇| 国产麻豆视频一区二区| 一区二区成人在线| 国产丝袜美腿一区二区三区| 在线不卡中文字幕| av不卡在线播放| 狠狠色狠狠色综合| 日韩影视精彩在线| 日韩理论在线观看| 国产亚洲福利社区一区| 欧美一区二区三区人| 色综合夜色一区| 国产精品一区二区黑丝| 亚洲成av人片在线| 亚洲精品免费一二三区| 久久综合av免费| 日韩一区二区中文字幕| 欧美日韩大陆一区二区| 色婷婷狠狠综合| 99久久99精品久久久久久| 国产乱码精品一品二品| 精品一区中文字幕| 精品一区二区在线观看| 琪琪久久久久日韩精品| 亚洲成人免费av| 亚洲福利一二三区| 亚洲午夜免费视频| 亚洲国产va精品久久久不卡综合| 亚洲欧美日本韩国| 自拍av一区二区三区| 国产精品福利影院| 亚洲欧洲99久久| 亚洲欧美另类久久久精品2019| 国产精品久线观看视频| 国产免费观看久久| 欧美国产精品一区| 中文字幕色av一区二区三区| 国产欧美日韩久久| 综合婷婷亚洲小说| 一区二区三区美女| 首页亚洲欧美制服丝腿| 亚洲成a天堂v人片| 日韩av成人高清| 九一九一国产精品| 国产精品一二三四五| 成人性生交大片免费看中文| 成人av电影在线| 97国产精品videossex| 色噜噜狠狠一区二区三区果冻| 色妹子一区二区| 欧美日韩国产一区| 欧美精品一区二区三区很污很色的| 久久久久国产精品厨房| 成人欧美一区二区三区在线播放| 一区av在线播放| 日韩av一区二区三区四区| 国产一区二区三区免费在线观看| 成人高清免费观看| 在线欧美日韩精品| 日韩欧美国产精品一区| 国产亚洲视频系列| 亚洲在线一区二区三区| 精品在线免费观看| 91麻豆国产自产在线观看| 欧美日韩夫妻久久| 国产欧美日产一区| 亚洲成人av一区二区| 国产成人免费视频网站高清观看视频 | 成人中文字幕电影| 日本精品一区二区三区四区的功能| 欧美猛男男办公室激情| 久久精品免费在线观看| 亚洲成人动漫精品| 成人av小说网| 日韩一区二区三区免费看| 最新热久久免费视频| 麻豆精品在线视频| 欧美日韩免费电影| 国产精品二三区| 久久99国产精品免费|