15,979
社区成员
发帖
与我相关
我的任务
分享
BITMAP bm;
COLORREF m_rgb;
m_r=0,m_g=0,m_b=0;//int
m_bmp-> GetObject(sizeof(bm),(LPVOID)&bm);//CBitmap *m_bmp;
memDC.SelectObject(&m_bmp);
int rx,ry;
for(rx=0;rx<bm.bmWidth;rx++)
{
for(ry=0;ry<bm.bmHeight;ry++)
{
m_rgb=memDC.GetPixel(rx, ry);
m_r+= GetRValue(m_rgb);//R
m_g+= GetGValue(m_rgb);//G
m_b+= GetBValue(m_rgb);//B
}
}
int colorpoint=bm.bmWidth*bm.bmHeight;
m_r=m_r/colorpoint;
m_g=m_g/colorpoint;
m_b=m_b/colorpoint;
int rx,ry;
int colorpoint=bm.bmWidth*bm.bmHeight;
for(rx=0;rx<bm.bmWidth;rx++)
{
for(ry=0;ry<bm.bmHeight;ry++)
{
m_rgb=memDC.GetPixel(rx, ry);
m_r+= GetRValue(m_rgb);//R
m_g+= GetGValue(m_rgb);//G
m_b+= GetBValue(m_rgb);//B
m_r=m_r/colorpoint;
m_g=m_g/colorpoint;
m_b=m_b/colorpoint;
}
}