天天看点

VS2010-MFC内显示图片

void CmyImage006View::OnDraw(CDC *pDC)
{
  /*
  CmyImage006Doc* pDoc = GetDocument();
  ASSERT_VALID(pDoc);
  if (!pDoc)
    return;
    */
  CBitmap bitmap;
  CDC cmc;
  bitmap.LoadBitmapW(IDB_BITMAP2);
  BITMAP bmp;
  bitmap.GetBitmap(&bmp);
  //bitmap.GetBitmap(&bmp);
  
  cmc.CreateCompatibleDC(pDC);
  cmc.SelectObject(&bitmap);
  //pDC->BitBlt(0,0,619,619,&cmc,0,0,SRCCOPY);
//  pDC->StretchBlt(0,0,619/2,619/2,&cmc,0,0,619,619,SRCCOPY);
  //pDC->BitBlt(0,0,800,800,&cmc,0,0,SRCCOPY);
  CRect cm;
  GetClientRect(&cm);
//  pDC->StretchBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,1024,1024,SRCCOPY);
//  pDC->BitBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,SRCCOPY);
  //pDC->StretchBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
  pDC->StretchBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
  // TODO: add draw code for native data here
}      

继续阅读