请教picture控件中图像的缩放(StretchBlt)
void CStretchImageDlg::OnStretchImage(){ CRect r; m_picture.GetClientRect(&r);//m_picture为picture控件对应变量(control) CDC* pDC = m_picture.GetDC(); //填充背景 pDC->FillRect(&r,NULL); //将位图选进设备场景中 CBitmap cbmp; cbmp.LoadBitmap(IDB_BITMAP1); CDC memdc; memdc.CreateCompatibleDC(pDC); memdc.SelectObject(&cbmp); BITMAP bmp; //获得位图参数 long width,height; cbmp.GetBitmap(&bmp); width = bmp.bmWidth; height = bmp.bmHeight; //缩放位图为原来的50% pDC->StretchBlt(r.left,r.top,(int)(width*0.5),(int)(height*0.5), &memdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);}