CImage将图片转为指定像素大小
CFileDialog fDlg(true, "jpg", "", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "JPG files (*.jpg)|*.jpg|");
if (fDlg.DoModal () != IDOK) return;
CImage imSrc,imDest;
imSrc.Load( fDlg.GetPathName());
HDC hDC = imSrc.GetDC();
CDC *pDC = CDC::FromHandle(hDC);
CBitmap bmp;
bmp.CreateCompatibleBitmap(pDC,152,200);
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap *pOld =memDC.SelectObject(&bmp);
::SetStretchBltMode(memDC.m_hDC,HALFTONE);
::SetBrushOrgEx(memDC.m_hDC,0,0,NULL);
imSrc.StretchBlt(memDC.m_hDC,CRect(0,0,152,200)/*DestRect*/,CRect(0,0,imSrc.GetWidth(),imSrc.GetHeight())/*SourceRect*/,SRCCOPY);
//152,200就是你想要的图像的宽和高(以像素为单位)
HBITMAP hBitmap=(HBITMAP)memDC.SelectObject(pOld->m_hObject);
imDest.Attach(hBitmap);// 载入位图资源
CFileDialog fDlg1(false, "bmp", "", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "BMP files (*.bmp)|*.bmp|");
if (fDlg1.DoModal () != IDOK) return;
imDest.Save(fDlg1.GetPathName());
imSrc.ReleaseDC();
imSrc.Destroy();
imDest.Destroy();