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

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

?? ch15.htm

?? 一天之內學會VC#. 主要介紹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一区二区三区免费野_久草精品视频
蜜桃免费网站一区二区三区| 欧美精品粉嫩高潮一区二区| 国产麻豆精品在线观看| 久久99久久久欧美国产| 国产福利一区二区| 91在线porny国产在线看| 日本韩国一区二区| 欧美日韩高清一区二区三区| 精品88久久久久88久久久| 国产日本欧美一区二区| 亚洲视频中文字幕| 五月天激情综合网| 国产福利一区二区| 91视频免费观看| 欧美成人在线直播| 亚洲男人天堂av| 国内精品视频一区二区三区八戒| 国产69精品久久99不卡| 欧美日韩成人一区| 欧美国产一区二区在线观看| 日韩激情视频网站| 91免费版pro下载短视频| 欧美一区二区三区在| 中文字幕在线不卡一区| 国产一区二区女| 日韩一级片在线播放| 亚洲制服欧美中文字幕中文字幕| 国产精品香蕉一区二区三区| 亚洲精品一线二线三线| 日韩电影在线观看电影| 日本高清视频一区二区| 亚洲欧洲一区二区在线播放| 99在线精品观看| 国产综合色在线视频区| 激情久久五月天| 欧美一区欧美二区| 中文字幕久久午夜不卡| 成人18精品视频| 中文字幕亚洲区| 欧美午夜精品一区二区蜜桃| 亚洲国产va精品久久久不卡综合| 在线免费av一区| 久久精品久久久精品美女| 久久久久国色av免费看影院| 成人亚洲一区二区一| 一区二区三区在线看| 777亚洲妇女| av网站一区二区三区| 亚洲成人动漫在线观看| 国产午夜亚洲精品羞羞网站| 91日韩在线专区| 九九视频精品免费| 亚洲婷婷综合久久一本伊一区| 欧美军同video69gay| 成人动漫精品一区二区| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲国产精品ⅴa在线观看| 欧美在线不卡一区| 成人av在线观| 国产精品一区二区你懂的| 亚洲18影院在线观看| 18欧美亚洲精品| 中文字幕精品一区二区精品绿巨人| 欧美日韩在线观看一区二区| 成人av午夜电影| 成人av资源站| 成人在线视频一区二区| 国产精品自拍在线| 久88久久88久久久| 午夜日韩在线观看| 国产精品毛片高清在线完整版| 2020日本不卡一区二区视频| 欧美日韩精品专区| 欧美日韩免费电影| 欧美日本乱大交xxxxx| 欧美日韩免费观看一区三区| 色拍拍在线精品视频8848| 91蜜桃视频在线| 欧美日韩国产不卡| 91在线免费看| 亚洲精品视频一区| 亚洲人成电影网站色mp4| 欧美激情在线免费观看| 国产精品对白交换视频| 国产精品久久久久国产精品日日| 国产精品污网站| 五月天精品一区二区三区| 蜜臀久久久99精品久久久久久| 精品制服美女丁香| 色综合一区二区三区| 一本大道久久a久久精二百| 91国模大尺度私拍在线视频| 欧美不卡在线视频| 亚洲在线视频网站| 成a人片亚洲日本久久| 欧美变态tickle挠乳网站| 亚洲人吸女人奶水| 国产激情偷乱视频一区二区三区| 欧美日韩一级视频| 亚洲乱码一区二区三区在线观看| 免费在线看成人av| 欧美私模裸体表演在线观看| 国产精品福利影院| 国产精品全国免费观看高清| 看片的网站亚洲| 亚洲自拍偷拍综合| 不卡的av电影在线观看| 欧美精品一区二区三区蜜臀| 午夜av一区二区| 欧美日韩五月天| 亚洲福利国产精品| 国产精品久久久久久久久免费丝袜 | 欧美一区二区二区| 一二三区精品视频| 国产成人av福利| 欧美精品欧美精品系列| 香蕉久久夜色精品国产使用方法| 在线观看网站黄不卡| 亚洲综合一二三区| 欧美电影免费观看完整版| 欧美剧情电影在线观看完整版免费励志电影 | 国产精品无码永久免费888| 国产精品一色哟哟哟| 亚洲欧洲国产日韩| 欧美精品日韩精品| 成人h动漫精品一区二区| 夜夜爽夜夜爽精品视频| 日韩一卡二卡三卡国产欧美| 国产成人aaa| 天涯成人国产亚洲精品一区av| 91久久奴性调教| 亚洲精品你懂的| 日韩欧美一区中文| 91美女蜜桃在线| 丝袜亚洲精品中文字幕一区| 国产精品国模大尺度视频| 欧美mv日韩mv亚洲| 91福利精品视频| 国产精品一区二区男女羞羞无遮挡| 一区二区三区日韩精品视频| 2023国产一二三区日本精品2022| 色婷婷激情久久| 高清在线观看日韩| 国内国产精品久久| 免费精品视频最新在线| 奇米综合一区二区三区精品视频 | 一区二区三区四区不卡在线| 精品成人私密视频| 久久蜜桃av一区精品变态类天堂| 69堂精品视频| 日韩你懂的电影在线观看| 欧美三片在线视频观看| 日韩一级免费一区| 欧美不卡一区二区三区四区| 日本不卡一二三区黄网| 免费在线欧美视频| 免费成人在线观看| 国产白丝精品91爽爽久久| 国产69精品久久久久毛片| 91色九色蝌蚪| 日韩一区二区在线观看| 欧美经典三级视频一区二区三区| 久久久综合精品| 久久综合狠狠综合| 成人免费看的视频| 天天操天天综合网| 九九九精品视频| 99综合影院在线| 日韩精品一区二区三区在线| 国产精品理论片在线观看| 午夜精品久久久久久久久久| 国产在线乱码一区二区三区| 色噜噜狠狠色综合欧洲selulu| 日韩一区二区中文字幕| 亚洲精品国产成人久久av盗摄 | 精品奇米国产一区二区三区| 久久久久国产免费免费| 久久成人免费网站| 欧美一区国产二区| 天堂蜜桃一区二区三区| proumb性欧美在线观看| 国产精品久久久久久久第一福利| 免费成人在线网站| 精品不卡在线视频| 久久综合色天天久久综合图片| 精品国产第一区二区三区观看体验| 亚洲欧美激情插| 一区二区三区欧美激情| 久久99精品网久久| 欧美成人精精品一区二区频| 琪琪久久久久日韩精品| 日韩欧美在线一区二区三区| 蜜桃久久久久久| 国产亚洲1区2区3区| 成人av电影在线| 亚洲精品中文字幕在线观看| 色94色欧美sute亚洲线路一ni| 亚洲美女屁股眼交3| 欧美一级专区免费大片| 精品一区二区国语对白|