?? subject_33828.htm
字號:
<p>
序號:33828 發表者:達文西 發表日期:2003-03-24 15:46:54
<br>主題:關于在ImageList中加入BMP
<br>內容:項目文件夾下面有一個BMP(24位)圖像。p1.bmp<BR>我在程序里面用:<BR>CImageList m_Image;<BR>m_Image.Create("p1.bmp",50,0,RGB(0,0,0));<BR>m_Image.Draw(pDC,CPoint(100,100),ILD_TRANSPARENT);時會出錯。<BR><BR>請高手指點原因。<BR>謝謝!
<br><a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p>
<hr size=1>
<blockquote><p>
回復者:小年 回復日期:2003-03-24 16:25:56
<br>內容:應該為:(運行結果如下圖所示)<BR>CImageList m_Image;<BR>m_Image.Create(IDB_BITMAP_TEST, 400, 0, RGB(0,0,0));<BR>m_Image.Draw(pDC, 0, CPoint(100,100), ILD_TRANSPARENT);//4個參數
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
回復者:達文西 回復日期:2003-03-24 17:15:07
<br>內容:m_Image.Draw(pDC, 0, CPoint(100,100), ILD_TRANSPARENT);//4個參數<BR>是我抄錯。<BR><BR>我是要加載不是由VC制作的BITMAP。而是由其它軟件制作的BMP圖片,所以不能以IDB_BITMAP_TEST為參數。<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
回復者:小年 回復日期:2003-03-24 18:08:17
<br>內容:你是說打開一個bmp文件,而不是從exe文件加載位圖吧!<BR>那你m_Image.Create("p1.bmp",50,0,RGB(0,0,0));可定錯了,Create()是直接從exe文件加載位圖的,可別以為參數是"p1.bmp"就認為可加載位文件了,它跟ID(比如IDB_BITMAP_TEST)基本沒區別的,請看下圖:只是命名方式不一樣而已哦!<BR>
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
回復者:達文西 回復日期:2003-03-25 08:25:09
<br>內容:xiaonian:<BR> 那我到底該怎樣加載呢?<BR> 謝謝!
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
回復者:小年 回復日期:2003-03-25 16:16:46
<br>內容:void CDemo1View::OnDraw(CDC* pDC)<BR>{<BR> CDemo1Doc* pDoc = GetDocument();<BR> ASSERT_VALID(pDoc);<BR> // TODO: add draw code for native data here<BR><BR> CImageList m_Image;<BR><BR> //讀取位圖文件<BR> HBITMAP hbitmap;<BR> CString m_sPath = "f:\\a.bmp"; //根據需要自行設計<BR> hbitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), m_sPath, <BR> IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); <BR> if (hbitmap == NULL)<BR> {<BR> AfxMessageBox("該文件打開錯誤!");<BR> return;<BR> }<BR><BR> //將hbitmap關聯至CBitmap對象<BR> CBitmap bitmap; <BR> bitmap.Attach(hbitmap);<BR> BITMAP info;<BR> bitmap.GetBitmap(&info);<BR> m_Image.Create(info.bmWidth, info.bmHeight, ILC_COLOR4, 0, 0);<BR> <BR><BR> m_Image.Add(&bitmap, RGB(0, 0, 0));<BR><BR> m_Image.Draw(pDC, 0, CPoint(100,100), ILD_TRANSPARENT);<BR>}<BR><BR><BR>注意:m_Image.Create(400, 300, ILC_COLOR8, 0, 0)第三個參數設定<BR>Set of bit flags that specify the type of image list to create. This parameter can be a combination of the following values, but it can include only one of the ILC_COLOR values. ILC_COLOR Use the default behavior if none of the other ILC_COLOR* flags is specified. Typically, the default is ILC_COLOR4, but for older display drivers, the default is ILC_COLORDDB. <BR>ILC_COLOR4 Use a 4-bit (16-color) device-independent bitmap (DIB) section as the bitmap for the image list. <BR>ILC_COLOR8 Use an 8-bit DIB section. The colors used for the color table are the same colors as the halftone palette. <BR>ILC_COLOR16 Use a 16-bit (32/64k-color) DIB section. <BR>ILC_COLOR24 Use a 24-bit DIB section. <BR>ILC_COLOR32 Use a 32-bit DIB section. <BR>ILC_COLORDDB Use a device-dependent bitmap. <BR>ILC_MASK Use a mask. The image list contains two bitmaps, one of which is a monochrome bitmap used as a mask. If this value is not included, the image list contains only one bitmap. <BR><BR>2003-3-25 16:31:09
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -