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

📄 subject_43591.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:43591 发表者:hanlei 发表日期:2003-06-12 13:13:48
<br>主题:请问怎样让用LoadImage()函数读出的bmp图显示在屏幕上?
<br>内容:<BR><BR>由于我的程序中不能用MFC,所以不能用CDC类的成员,那么怎样让LoadImage()函数读出的bmp图显示在屏幕上呢?或者用别的什么函数,多谢帮忙!<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:michael 回复日期:2003-06-12 13:25:45
<br>内容:BOOL StretchBlt(<BR>&nbsp;&nbsp;HDC hdcDest,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// handle to destination device context<BR>&nbsp;&nbsp;int nXOriginDest, // x-coordinate of upper-left corner of dest. rectangle<BR>&nbsp;&nbsp;int nYOriginDest, // y-coordinate of upper-left corner of dest. rectangle<BR>&nbsp;&nbsp;int nWidthDest,&nbsp;&nbsp; // width of destination rectangle<BR>&nbsp;&nbsp;int nHeightDest,&nbsp;&nbsp;// height of destination rectangle<BR>&nbsp;&nbsp;HDC hdcSrc,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // handle to source device context<BR>&nbsp;&nbsp;int nXOriginSrc,&nbsp;&nbsp;// x-coordinate of upper-left corner of source rectangle<BR>&nbsp;&nbsp;int nYOriginSrc,&nbsp;&nbsp;// y-coordinate of upper-left corner of source rectangle<BR>&nbsp;&nbsp;int nWidthSrc,&nbsp;&nbsp;&nbsp;&nbsp;// width of source rectangle<BR>&nbsp;&nbsp;int nHeightSrc,&nbsp;&nbsp; // height of source rectangle<BR>&nbsp;&nbsp;DWORD dwRop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // raster operation code<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>
回复者:hanlei 回复日期:2003-06-12 21:30:55
<br>内容:<BR>它怎样和LoadImage函数联系上呢?<BR>它用的是HDC结构 ,但是LoadImage用的是HINSTANCE结构。<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-06-13 13:59:04
<br>内容:CBitmap bt;<BR>bt.m_hBitmap=::LoadImage(......)
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:(zl剑客) 回复日期:2003-06-13 17:12:14
<br>内容:你的是WINDOWS 程序还是MFC<BR> LoadImage返回资源的句柄<BR>利用这个句柄就可以将他显示了<BR>不过还的创建内存DC,将位图选进来<BR>然后通过 BitBlt StretchBlt画出
<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-06-14 07:46:19
<br>内容:<BR>BITMAP bm;<BR>HBITMAP hBmp,hOld;<BR><BR>hBmp = LoadBitmap(hInstance,MAKEINTRESOURCE(ID_BITMAP));<BR>HDC hdc=GetDC(hWnd);<BR>hMem=CreateCompatibleDC(hdc);<BR><BR>GetObject(hBmp,sizeof(BITMAP),&amp;bm)<BR>hOld=SelectObject(hMem,hBmp);<BR><BR>RECT rect;<BR>GetClientRect(hWnd,&amp;rect);<BR><BR>StretchBlt(hdc,rect.left,rect.top,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rect.right-rect.left,rect.bottom-rect.top,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hMem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);<BR><BR><BR>hBmp=SelectObject(hMem,hOld);<BR>DelectDC(hMem);<BR>DelectObject(hBmp);
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -