急!!求助!100分在线等待!~~~双缓存画图,是否只能画黑白色图?我想画高位的彩图,但是显示的却老是黑白色图,而且添家颜色也不行,望高手指教,最好有源代码,在线等待!~
下面是我的代码片段:
// 初始化和双缓冲相关的要素
void CDBBTestView::InitialDBB()
{
CRect rt;
this->GetClientRect(&rt); // 为屏幕DC创建兼容的内存DC
if(!m_dcMemory.CreateCompatibleDC(NULL)) 我感觉是这里的问题,可能创建的是光栅设备环境,画图只能是单色的,但是画高色的方法却没有,也许没找到,望大虾指教
{
::PostQuitMessage(0);
} // 创建位图
m_Bmp.CreateCompatibleBitmap(&m_dcMemory, rt.Width(), rt.Height()); // 相当于选择画布
::SelectObject(m_dcMemory.GetSafeHdc(), m_Bmp);
}下面函数是画图void CDBBTestView::DrawManyCircleUseDBB()
{
// 在View内用双缓冲画很多的圆 CDC *pdcView = this->GetDC(); CRect rt;
this->GetClientRect(&rt); m_dcMemory.FillSolidRect(&rt, 0x00FFFFFF); // 白色填充, 注意,这次是画在内存设备环境上 // 画圆
for(int i = 0; i < rt.Width() - 1; i+= 16)
{
for(int j = 0; j < rt.Height() - 1; j+= 16)
{
m_dcMemory.Ellipse(i, j, i + m_nRadius, j + m_nRadius);
}
} // 一次性的将内存设备环境上绘制完毕的图形"贴"到屏幕上
pdcView->BitBlt(0, 0, rt.Width(), rt.Height(), &m_dcMemory, 0, 0, SRCCOPY); this->ReleaseDC(pdcView); // 释放view的设备环境
}
急!!在线着急等待,help!~
下面是我的代码片段:
// 初始化和双缓冲相关的要素
void CDBBTestView::InitialDBB()
{
CRect rt;
this->GetClientRect(&rt); // 为屏幕DC创建兼容的内存DC
if(!m_dcMemory.CreateCompatibleDC(NULL)) 我感觉是这里的问题,可能创建的是光栅设备环境,画图只能是单色的,但是画高色的方法却没有,也许没找到,望大虾指教
{
::PostQuitMessage(0);
} // 创建位图
m_Bmp.CreateCompatibleBitmap(&m_dcMemory, rt.Width(), rt.Height()); // 相当于选择画布
::SelectObject(m_dcMemory.GetSafeHdc(), m_Bmp);
}下面函数是画图void CDBBTestView::DrawManyCircleUseDBB()
{
// 在View内用双缓冲画很多的圆 CDC *pdcView = this->GetDC(); CRect rt;
this->GetClientRect(&rt); m_dcMemory.FillSolidRect(&rt, 0x00FFFFFF); // 白色填充, 注意,这次是画在内存设备环境上 // 画圆
for(int i = 0; i < rt.Width() - 1; i+= 16)
{
for(int j = 0; j < rt.Height() - 1; j+= 16)
{
m_dcMemory.Ellipse(i, j, i + m_nRadius, j + m_nRadius);
}
} // 一次性的将内存设备环境上绘制完毕的图形"贴"到屏幕上
pdcView->BitBlt(0, 0, rt.Width(), rt.Height(), &m_dcMemory, 0, 0, SRCCOPY); this->ReleaseDC(pdcView); // 释放view的设备环境
}
急!!在线着急等待,help!~
解决方案 »
- 急。VS2005安装xtreme toolkitpro遇到的问题
- VPN虚拟网SOCKET通信问题
- 为什么在一个类中定义另一个类的对象,却无法调用该类的成员函数?
- 因为这个问题已经郁闷了30分钟了,帮下忙看看,不胜感激.....
- 关于vtalbe 里面的虚函数
- 如何实现midi和wav文件之间的转换
- 征求一种数据容器的解决方案~~~思想~~~~
- 请问怎么将_variant_t 变量转换为char *
- 《Visual C++ 技术内幕》(第四版)这书怎样?适合初学者吗?
- 可爱的C++编译器
- CHtmlview 加载一个网页该网页只有一个FLASH,导航后显示不全,最小化后还原显示的内容更少
- 急!!求助!100分在线等待!~~~双缓存画图,是否只能画黑白色图?我想画高位的彩图,但是显示的却老是黑白色图,而且添家颜色也不行,望高手指教,最好有源代码,在线等待!~
{
...
CMemDc dcMemory;
CBitmap Bmp;
dcMemory.CreateCompatibleDC(pDC) //创建与指定 DC 兼容的内存 DC。
Bmp.CreateCompatibleBitmap(pDC, rt.Width(), rt.Height()); //不要使用 &dcMemory。
...
}
CDC* pDesktopDC = GetDC(GetDesktopWindow());
if(!m_dcMemory.CreateCompatibleDC(pDesktopDC )) 我感觉是这里的问题,可能创建的是光栅设备环境,画图只能是单色的,但是画高色的方法却没有,也许没找到,望大虾指教
{
::PostQuitMessage(0);
} // 创建位图
m_Bmp.CreateCompatibleBitmap(pDesktopDC , rt.Width(), rt.Height());
{
CClientDC dc(this);
CRect rt;
this->GetClientRect(&rt);
if(!m_dcMemory.CreateCompatibleDC(&dc))
{
::PostQuitMessage(0);
}
m_Bmp.CreateCompatibleBitmap(&dc, rt.Width(), rt.Height());
::SelectObject(m_dcMemory.GetSafeHdc(), m_Bmp);
}
OnDraw(CDC* pDC)
{
CDC dc;
CDC* pDrawDC = pDC;
CBitmap bitmap;
CBitmap* pOldBitmap = 0; // only paint the rect that needs repainting
CRect client;
pDC->GetClipBox(client);
CRect rect = client;
DocToClient(rect); if (!pDC->IsPrinting())
{
// draw to offscreen bitmap for fast looking repaints
if (dc.CreateCompatibleDC(pDC))
{
if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()))
{
OnPrepareDC(&dc, NULL);
pDrawDC = &dc; // offset origin more because bitmap is just piece of the whole drawing
dc.OffsetViewportOrg(-rect.left, -rect.top);
pOldBitmap = dc.SelectObject(&bitmap);
dc.SetBrushOrg(rect.left % 8, rect.top % 8); // might as well clip to the same rectangle
dc.IntersectClipRect(client);
}
}
} // 绘制到内存DC
XXXX.Draw( pDrawDC); // 把内存DC内容贴到pDC上
if (pDrawDC != pDC)
{
pDC->SetViewportOrg(0, 0);
pDC->SetWindowOrg(0,0);
pDC->SetMapMode(MM_TEXT);
dc.SetViewportOrg(0, 0);
dc.SetWindowOrg(0,0);
dc.SetMapMode(MM_TEXT);
pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
&dc, 0, 0, SRCCOPY);
dc.SelectObject(pOldBitmap);
}}