哪位朋友可以给一个使用CMemDC绘制位图的示例? 网上找了很多,都不清不楚。。有人可以写一下么?位图已经添加到了资源里。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 最简单的,还用双缓存了,呵呵 CDC memdc; CBitmap bmp; BITMAP pbmp; int i_width; int i_height; bmp.LoadBitmap(IDB_BITMAP1); bmp.GetBitmap(&pbmp); i_width = pbmp.bmWidth; i_height = pbmp.bmHeight; memdc.CreateCompatibleDC(NULL); memdc.SelectObject(bmp); //整幅图拷贝 pDC->BitBlt(0,0,i_width,i_height,&memdc,0,0,SRCCOPY); 加载什么的楼主可以卸载OnInitDialog或者OnInitUpdate里面,pDC->输出一定要在On_Paint里控制 嗟夫。自己回贴吧:正确方案:void CGamepadPaintView::OnPaint(){ CPaintDC dcWnd(this); CMemDC dc(&dcWnd); DrawImg(dc, m_Bitmap, IDB_BITMAP_SIGN_DIRECT, 10, 10, 80, 80);}void CGamepadPaintView::DrawImg(CDC& dc, CBitmap& bitmap, DWORD bmpID, int x, int y, int width, int height, DWORD colorkey/*=0x000000*/){ CDC ImageDC; CBitmap* pOldImageBMP = NULL; bitmap.LoadBitmap(bmpID); ImageDC.CreateCompatibleDC(&dc); pOldImageBMP = ImageDC.SelectObject(&bitmap); TransparentBlt(dc.m_hDC, x, y, width, height, ImageDC.m_hDC, 0, 0, width, height, colorkey); // colorkey为关键色作透明色 ImageDC.SelectObject(pOldImageBMP); bitmap.DeleteObject();} 自绘圆角按钮问题 关于调试的一个问题请教? 如何改变BUTTON中显示的字体大小? 添加数据问题 同一个dll如何在不同进程中共享变量?? 关于DLL连接问题的疑惑? 怎么打开有密码的数据库 再问此题 请问如何在单文档的用户区从硬盘读取多个位图?? 这里没有真正的高手!!!不过是一些二流人员发泄的地方!您说那?嘿~~~~~~~~ 资料应该上传到哪里? 怎么获得不同对话框里面控件的变量的值?急!!!
CBitmap bmp;
BITMAP pbmp;
int i_width;
int i_height; bmp.LoadBitmap(IDB_BITMAP1);
bmp.GetBitmap(&pbmp);
i_width = pbmp.bmWidth;
i_height = pbmp.bmHeight;
memdc.CreateCompatibleDC(NULL);
memdc.SelectObject(bmp); //整幅图拷贝
pDC->BitBlt(0,0,i_width,i_height,&memdc,0,0,SRCCOPY);
正确方案:
void CGamepadPaintView::OnPaint()
{
CPaintDC dcWnd(this);
CMemDC dc(&dcWnd); DrawImg(dc, m_Bitmap, IDB_BITMAP_SIGN_DIRECT, 10, 10, 80, 80);
}void CGamepadPaintView::DrawImg(CDC& dc, CBitmap& bitmap, DWORD bmpID, int x, int y, int width, int height, DWORD colorkey/*=0x000000*/)
{
CDC ImageDC;
CBitmap* pOldImageBMP = NULL; bitmap.LoadBitmap(bmpID);
ImageDC.CreateCompatibleDC(&dc);
pOldImageBMP = ImageDC.SelectObject(&bitmap);
TransparentBlt(dc.m_hDC, x, y, width, height, ImageDC.m_hDC, 0, 0, width, height, colorkey); // colorkey为关键色作透明色
ImageDC.SelectObject(pOldImageBMP);
bitmap.DeleteObject();
}