如何在屏幕上同时显示多个位图?

dawei424 2008-04-15 10:25:25
按照下面的方法我可以显示一个图IDB_OPEN
CBitmap bitmap;
bitmap.LoadBitmap(IDB_OPEN);
CRect rect( 0, 0, 100, 100);
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(&bitmap);
pDC-> BitBlt( rect.left, rect.top, rect.Width(), rect.Height(),
&dcCompatible, 0, 0, SRCCOPY );
我现在想在屏幕不同位置显示多个位图,不知如何在内存中把多个位图画好,然后在贴到屏幕上,谢了。。。。。。。
...全文
179 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
meiZiNick 2008-04-30
  • 打赏
  • 举报
回复
等待牛人来答.
cnct41 2008-04-16
  • 打赏
  • 举报
回复
我给你一个绘制16屏的简单代码
代码还是基于你的示例代码
BOOL CChkCardDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default

CBitmap bitmap;
bitmap.LoadBitmap(IDB_OPEN);
CRect rect( 0, 0, 100, 100);
GetClientRect(&rect);
BITMAP bmp;
bitmap.GetBitmap(&bmp);
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDC);
dcCompatible.SelectObject(&bitmap);
for(int i = 0;i < 4;i++)
for(int j = 0;j < 4;j++)
pDC->StretchBlt( rect.left + (rect.Width() / 4 * i)
, rect.top + (rect.Height() / 4 * j)
, rect.Width() / 4, rect.Height() / 4,
&dcCompatible, 0, 0, bmp.bmWidth,bmp.bmHeight,SRCCOPY );
return TRUE;
return CDialog::OnEraseBkgnd(pDC);
}
scq2099yt 2008-04-16
  • 打赏
  • 举报
回复
切分窗口
然后LoadImage
dawei424 2008-04-15
  • 打赏
  • 举报
回复
比如:我要把Resource里的两个位图IDB_OPEN和IDB_CLOSE分别显示到屏幕的CRect rect( 0, 0, 100, 100) 和rect( 200, 200, 100, 100)的两个位置,代码怎么写,我是新手,请指教。
wflishh 2008-04-15
  • 打赏
  • 举报
回复
自己移动起点和终点的坐标位置来实现
ahuisafe 2008-04-15
  • 打赏
  • 举报
回复
CDC::StretchBlt
用这个
BOOL StretchBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop );
大小可以调整
Moves a bitmap from a source rectangle and device into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle.
dawei424 2008-04-15
  • 打赏
  • 举报
回复
那么我每一个图的位置怎么确定呢?
bbslucky 2008-04-15
  • 打赏
  • 举报
回复
再生成一个CompatibleDC吧,把几幅图刷到这个CompatibleDC上
然后再把CompatibleDC刷到pdc上
hndxh3000 2008-04-15
  • 打赏
  • 举报
回复
CBitmap bitmap1 , bitmap2;
bitmap1.LoadBitmap(IDB_OPEN);
CRect rect1( 0, 0, 100, 100);
CRect rect2( 200 , 200 , 100 , 100);
CDC dcCompatible1 , dcCompatible2;
dcCompatible1.CreateCompatibleDC(pDC);
dcCompatible1.SelectObject(&bitmap1);
dcCompatible2.CreateCompatibleDC(pDC);
dcCompatible2.SelectObject(&bitmap2);
pDC-> BitBlt( rect.left, rect.top, rect.Width(), rect.Height(),
&dcCompatible1, 0, 0, SRCCOPY );
pDC-> BitBlt( rect.left, rect.top, rect.Width(), rect.Height(),
&dcCompatible2, 0, 0, SRCCOPY );

按你的代码改的,如果你的代码没错,这份代码应该也能通过,不要说CSDN没热心人!!~
dawei424 2008-04-15
  • 打赏
  • 举报
回复
热心人哪去了?????

19,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧