using System.Drawing.Imaging;
public Image GrayScaleImage(Graphics graph, Image img, int left, int top)
{
ColorMatrix colorMix = new ColorMatrix();
colorMix.Matrix00 = 1 / 3f;
colorMix.Matrix01 = 1 / 3f;
colorMix.Matrix02 = 1 / 3f;
colorMix.Matrix10 = 1 / 3f;
colorMix.Matrix11 = 1 / 3f;
colorMix.Matrix12 = 1 / 3f;
colorMix.Matrix20 = 1 / 3f;
colorMix.Matrix21 = 1 / 3f;
colorMix.Matrix22 = 1 / 3f;
ImageAttributes imgAttrib = new ImageAttributes();
imgAttrib.SetColorMatrix(colorMix);
graph.DrawImage(img, new Rectangle(left, top, img.Width,
img.Height), 0, 0, img.Width, img.Height,
GraphicsUnit.Pixel, imgAttrib);
Bitmap bmp = new Bitmap(img);
return bmp;
}