⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_33828.htm

📁 vc
💻 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>&nbsp;&nbsp; 那我到底該怎樣加載呢?<BR>&nbsp;&nbsp; 謝謝!
<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>&nbsp;&nbsp;&nbsp;&nbsp;CDemo1Doc* pDoc = GetDocument();<BR>&nbsp;&nbsp;&nbsp;&nbsp;ASSERT_VALID(pDoc);<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: add draw code for native data here<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;CImageList m_Image;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;//读取位图文件<BR>&nbsp;&nbsp;&nbsp;&nbsp;HBITMAP hbitmap;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CString m_sPath = "f:\\a.bmp";&nbsp;&nbsp;//根据需要自行设计<BR>&nbsp;&nbsp;&nbsp;&nbsp;hbitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), m_sPath, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); <BR>&nbsp;&nbsp;&nbsp;&nbsp;if (hbitmap == NULL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox("该文件打开错误!");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;//将hbitmap关联至CBitmap对象<BR>&nbsp;&nbsp;&nbsp;&nbsp;CBitmap bitmap;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;bitmap.Attach(hbitmap);<BR>&nbsp;&nbsp;&nbsp;&nbsp;BITMAP info;<BR>&nbsp;&nbsp;&nbsp;&nbsp;bitmap.GetBitmap(&amp;info);<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_Image.Create(info.bmWidth, info.bmHeight, ILC_COLOR4, 0, 0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;m_Image.Add(&amp;bitmap, RGB(0, 0, 0));<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;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&nbsp;&nbsp;Use a 4-bit (16-color) device-independent bitmap (DIB) section as the bitmap for the image list.&nbsp;&nbsp;<BR>ILC_COLOR8&nbsp;&nbsp;Use an 8-bit DIB section. The colors used for the color table are the same colors as the halftone palette.&nbsp;&nbsp;<BR>ILC_COLOR16&nbsp;&nbsp;Use a 16-bit (32/64k-color) DIB section. <BR>ILC_COLOR24&nbsp;&nbsp;Use a 24-bit DIB section. <BR>ILC_COLOR32&nbsp;&nbsp;Use a 32-bit DIB section. <BR>ILC_COLORDDB&nbsp;&nbsp;Use a device-dependent bitmap. <BR>ILC_MASK&nbsp;&nbsp;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 + -