vc平铺位图
Code
void CFriendDlg::DrawPosImage( CBitmap *pBitmap, CDC *pDC, CPoint pt )
{
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap *pOldBitmap = (CBitmap*)MemDC.SelectObject(pBitmap);
BITMAP bm;
pBitmap->GetBitmap(&bm);
int li_Width = bm.bmWidth;
int li_Height = bm.bmHeight;
pDC->BitBlt(pt.x, pt.y, li_Width, li_Height, &MemDC, 0, 0, SRCCOPY);
MemDC.SelectObject(pOldBitmap);
MemDC.DeleteDC();
}
//平铺画位图
void CFriendDlg::DrawRangeImage(CBitmap *pBitmap, CDC *pDC, CRect rc)
{
CDC MemDC;
BITMAP bm;
pBitmap->GetBitmap(&bm);
int li_Width = bm.bmWidth;
int li_Height = bm.bmHeight;
MemDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(pBitmap);
int x=rc.left;
int y=rc.top;
while (y < (rc.Height()+rc.top))
{
while(x < (rc.Width()+rc.left))
{
pDC->BitBlt(x, y, li_Width, li_Height, &MemDC, 0, 0, SRCCOPY);
x += li_Width;
}
x = rc.left;
y += li_Height;
}
MemDC.SelectObject(pOldBitmap);
MemDC.DeleteDC();
}
void CFriendDlg::DrawPosImage( CBitmap *pBitmap, CDC *pDC, CPoint pt )
{
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap *pOldBitmap = (CBitmap*)MemDC.SelectObject(pBitmap);
BITMAP bm;
pBitmap->GetBitmap(&bm);
int li_Width = bm.bmWidth;
int li_Height = bm.bmHeight;
pDC->BitBlt(pt.x, pt.y, li_Width, li_Height, &MemDC, 0, 0, SRCCOPY);
MemDC.SelectObject(pOldBitmap);
MemDC.DeleteDC();
}
//平铺画位图
void CFriendDlg::DrawRangeImage(CBitmap *pBitmap, CDC *pDC, CRect rc)
{
CDC MemDC;
BITMAP bm;
pBitmap->GetBitmap(&bm);
int li_Width = bm.bmWidth;
int li_Height = bm.bmHeight;
MemDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(pBitmap);
int x=rc.left;
int y=rc.top;
while (y < (rc.Height()+rc.top))
{
while(x < (rc.Width()+rc.left))
{
pDC->BitBlt(x, y, li_Width, li_Height, &MemDC, 0, 0, SRCCOPY);
x += li_Width;
}
x = rc.left;
y += li_Height;
}
MemDC.SelectObject(pOldBitmap);
MemDC.DeleteDC();
}