如何先后向memDC写入2张Bitmap

code_cold 2001-11-22 03:31:42
CClientDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(m_cBitmap); // The first bitmap

// Then how to read the second bitmap, When display on the screen,
// it looks like the second image on the frist image surface ?

dc.BitBlt(0, 0, width, height, &memDC, 0, 0, SRCCOPY);
...全文
143 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
我以前也是啊,不过已经不用他了。
code_cold 2001-11-22
  • 打赏
  • 举报
回复
Very good
Very 谢谢 jiangping_zhu(娜可露露之风之刃) 

俺经常用橘佑京,鲜有对手
  • 打赏
  • 举报
回复
可能是memDC不够大,所以应该创佳一个足够大的图片来先直接创建。
我试过这样,是可以显示。
CClientDC dc(this);
CDC memDC;
CBitmap bitmap;
CBitmap bitmap1,bitmap2;
CBitmap* pBitmap1,*pBitmap2;
bitmap1.LoadBitmap(IDB_BITMAP1);
bitmap2.LoadBitmap(IDB_BITMAP2);
bitmap.CreateCompatibleBitmap(&dc,307+208,284+168);
memDC.CreateCompatibleDC(&dc);
CDC memDC2;
memDC2.CreateCompatibleDC(&memDC);

pBitmap2 = memDC2.SelectObject(&bitmap2); // The first bitmap

pBitmap1 = memDC.SelectObject(&bitmap);
memDC.BitBlt(0,0,307, 284, &memDC2, 0, 0, SRCCOPY);
memDC.BitBlt(50, 70, 307+208, 168, &memDC2, 0, 0, SRCCOPY);

dc.BitBlt(0, 0, 307+208,284+168, &memDC, 0, 0, SRCCOPY);
memDC2.SelectObject(pBitmap2);
memDC.SelectObject(pBitmap1);
code_cold 2001-11-22
  • 打赏
  • 举报
回复
In Cleint area,
dispaly two iamges
The second (it it smaller than the other) image on the first image surface
Looks like the firs image is a backgroud,
the second iamge is the user to see object
liu_feng_fly 2001-11-22
  • 打赏
  • 举报
回复
你想达到什么效果?
code_cold 2001-11-22
  • 打赏
  • 举报
回复
OK, 看下面的的代码有什摸问题,Nothing displayed also

CDC memDC;
memDC.CreateCompatibleDC(&dc);
CDC tempDC;
tempDC.CreateCompatibleDC(&dc);

tempDC.SelectObject(m_cBitmap); // The first image
memDC.BitBlt(0, 0, m_nWidth - 40, m_nHeight - 90, &tempDC, 0, 0, SRCCOPY);

dc.BitBlt(20, 20, m_nWidth - 20, m_nHeight - 70, &memDC, 0, 0, SRCCOPY);
roy_hu 2001-11-22
  • 打赏
  • 举报
回复
attention
  • 打赏
  • 举报
回复
你把
memDC.SelectObject(m_cBitmap2);
放到
memDC.BitBlt(0, 0, width, height, &memDC2, 0, 0, SRCCOPY);
之前,保证不要使图片覆盖,然后再试试。
code_cold 2001-11-22
  • 打赏
  • 举报
回复
Ok, as you said
I add the follwing

CClientDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CDC memDC2;
memDC2.CreateCompatibleDC(&memDC);

memDC2.SelectObject(m_cBitmap); // The first bitmap

memDC.BitBlt(0, 0, width, height, &memDC2, 0, 0, SRCCOPY);
memDC.SelectObject(m_cBitmap2);

dc.BitBlt(0, 0, width, height, &memDC, 0, 0, SRCCOPY);

But it doesn't work,
When I delete the line memDC.SelectObject(m_cBitmap2);
nothing displayed also



  • 打赏
  • 举报
回复
再创建一个memdc来载入图片,然后BitBlt到这个memDC上应该可以,不过意义不大。
code_cold 2001-11-22
  • 打赏
  • 举报
回复
哈哈,没人过来

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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