CImage img;
img.Load(_T("d:\\sex.bmp"));
COLORREF p;
int r,g,b,avg;
int width=img.GetWidth();
int height=img.GetHeight();
for(int x=0;x<width;x++)
{
for(int y=0;y<height;y++)
{
p=img.GetPixel(x,y);
r=GetRValue(p);
g=GetGValue(p);
b=GetBValue(p);
avg=(r+g+b)/3;
img.SetPixelRGB(x,y,avg,avg,avg);
}
}
img.Draw(GetDC()->m_hDC,CRect(0,0,width,height));
温馨提示:答案为网友推荐,仅供参考