📄 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 + -