// 绘制轨迹图像
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上绘制上百万级的点
最新推荐文章于 2019-01-15 09:41:49 发布