彩色图像转换为黑白

 public Bitmap Convert(Bitmap OldBm)
{
Color c;
int luma;
Bitmap NewBm = new Bitmap(OldBm.Width, OldBm.Height);
for (int y = 0; y < NewBm.Height; y++)
{
for (int x = 0; x < NewBm.Width; x++)
{
c = OldBm.GetPixel(x, y);
luma = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);
NewBm.SetPixel(x,y,Color.FromArgb(luma,luma,luma));
}
}
return NewBm;
}

posted @ 2011-09-21 16:37  绯色卡卡  阅读(251)  评论(0编辑  收藏  举报