如何在DC上绘制上百万级的点
2016-11-23 16:01
246 查看
// 绘制轨迹图像 void CImageLayerView::DrawTrackImage(CDC& dc_) { if (m_vecTrackImage.empty()) { return; } DWORD _dwBegin = GetTickCount(); CRect _rcClient; GetClientRect(&_rcClient); BITMAP _info; CBitmap _bitmapTemp; _bitmapTemp.CreateBitmap(_rcClient.Width(), _rcClient.Height(), 1, 32, NULL); _bitmapTemp.GetBitmap(&_info); CBitmap _bitmap; CDC _dcMemory; const int c_nSize = _rcClient.Width() * _rcClient.Height()*4; BYTE* _pBits = (BYTE*)new BYTE[c_nSize]; //::ZeroMemory(_pBits, c_nSize); memset(_pBits, 0xffffffff, _rcClient.Width() * _rcClient.Height()*4); /*for (int i = 0;i < _info.bmWidth;++i) { for (int j = 0;j < _info.bmHeight;++j) { _pBits[i * 4 + j * _info.bmWidthBytes + 2] = 0; _pBits[i * 4 + j * _info.bmWidthBytes + 1] = 0; _pBits[i * 4 + j * _info.bmWidthBytes + 0] = 255; } } */ for (int _j=0; _j<int(m_vecTrackImage.size()); _j++) { for (int _k=0;_k<int(m_vecTrackImage[_j].vecImageColor.size()); _k++) { FCDoub2D _pt; //_pt.x = m_vecTrackImage[_j].vecImageColor[_k].x; //_pt.y = m_vecTrackImage[_j].vecImageColor[_k].y; // _pt.x = _rcClient.right * m_fScale - (m_vecTrackImage[_j].vecImageColor[_k].x * m_fScale - m_ptMoveOffst.x); _pt.y = _rcClient.bottom * m_fScale - (m_vecTrackImage[_j].vecImageColor[_k].y * m_fScale - m_ptMoveOffst.y); if (_pt.x < 0. || _pt.y < 0. || _pt.x > _info.bmWidth || _pt.y > _info.bmHeight) { continue; } _pBits[int(_pt.x) * 4 + int(_pt.y) * _info.bmWidthBytes + 2] = GetRValue(m_vecTrackImage[_j].vecImageColor[_k].color); _pBits[int(_pt.x) * 4 + int(_pt.y) * _info.bmWidthBytes + 1] = GetGValue(m_vecTrackImage[_j].vecImageColor[_k].color); _pBits[int(_pt.x) * 4 + int(_pt.y) * _info.bmWidthBytes + 0] = GetBValue(m_vecTrackImage[_j].vecImageColor[_k].color); } } DWORD _dwEnd = GetTickCount() - _dwBegin; _bitmap.CreateBitmap(_rcClient.Width(), _rcClient.Height(), 1, 32, _pBits); _bitmap.SetBitmapBits(c_nSize, _pBits); _dcMemory.CreateCompatibleDC(&dc_); CBitmap *pbmpOld = _dcMemory.SelectObject(&_bitmap); dc_.BitBlt(0, 0, _rcClient.Width(), _rcClient.Height(), &_dcMemory, 0, 0, SRCCOPY); _dcMemory.SelectObject(pbmpOld); delete _pBits; _pBits = NULL; }
相关文章推荐
- 如何将内存中的位图数据绘制在DC上
- 如何将内存中的位图数据绘制在DC上
- 如何将内存中的位图数据绘制在DC上
- 如何将内存中的位图数据绘制在DC上
- Visual Basic 2005——如何在DataGridView控件的数据列标题上绘制编号
- [转贴]如何在ASP.NET中用OWC绘制图表
- 如何绘制半透明位图
- 如何在ASP.NET中用OWC绘制图表(2)
- 如何在ASP.NET中用OWC绘制图表 (2
- 如何根据离散点自动绘制等值线(等高线)之 三角形法
- VB 2005 - 读者询问 DrawString 问题—如何根据用户自己选择的颜色来绘制
- 如何在ASP.NET中用OWC绘制图表
- [愚翁专栏]如何在窗体以外的地方绘制图像
- 如何在窗体以外的地方绘制图像
- vb.net中如何快速绘制鼠标移动轨迹
- VB 2005 - 读者询问 DrawString 问题—如何根据用户自己选择的颜色来绘制
- 如何在窗体以外的地方绘制图像
- 如何在ASP.NET中用OWC绘制图表 (1)
- 如何绘制平滑的反走样线
- Visual Basic 2005 - 用户询问如何绘制圆饼图