{
CImage img;
    HRESULT  hRet;
    try
    {
    hRet = img.Load(szSourcePath);
        if(hRet == S_FALSE)
    return FALSE;
    }
    catch(...)
    {
        CString strError;
        strError.Format("读入图片%s异常。", szSourcePath);
        g_MainApp.WriteErroLog(strError.GetBuffer());
        return FALSE;
    }

if(bConvert)//如果图片格式不标准则需要另存为以便转化格式
{
CString strTmpPath;
for(int i=(int)strlen(szSourcePath);i>0;i--)
{
if(szSourcePath[i] == '.')
{
strTmpPath = CString(szSourcePath,i)+".jpg";
img.Save(strTmpPath,Gdiplus::ImageFormatPNG);
img.Destroy();
img.Load(strTmpPath);
break;
}
}
} COLORREF pixel;
int maxY = img.GetHeight();
int maxX = img.GetWidth(); //int m_nSmallWidth; //小图的长
//int m_nSmallHight; //小图的高
//高/宽 b/a > y/x 用源远流长图的高 否则用原图的宽
double dbRate;
if(m_nSmallWidth* maxY>m_nSmallHight * maxX )
{
dbRate = (double)maxY/m_nSmallHight;
}
else
{
dbRate = (double)maxX/m_nSmallWidth;
}
int x =  (int)(maxX/dbRate);
int y = (int)(maxY/dbRate);
if(x%2 == 1)
{
x -=1;
}
if(y%2 == 1)
{
y -=1;
} CImage sImg;
sImg.Create(x,y,img.GetBPP());
byte r,g,b;
for (int i=0; i<x; i++) 
{
for (int j=0; j<y; j++) 
{
pixel = img.GetPixel((int)(dbRate*i),int(dbRate*j));
r = GetRValue(pixel);
g = GetGValue(pixel);
b = GetBValue(pixel);
sImg.SetPixelRGB(i,j,r,g,b);
}
}
    if(sImg.Save(szSmallPath,Gdiplus::ImageFormatPNG) == S_OK)
return TRUE;
return FALSE;
}我是想把图片变成一个缩小的图片。但是达不到效果。请牛人帮我看看