Bitmap bmp = new Bitmap(pictureBox1.Image); int height = bmp.Height; int width = bmp.Width; Bitmap tmp = new Bitmap(width, height); Color c; int r, g, b, Result = 0; for (int i = 0; i < width; i++) for (int j = 0; j < height; j++) { c = bmp.GetPixel(i, j); r = c.R; g = c.G; b = c.B; //以加权平均值法产生黑白图像 Result = ((int)(0.7 * r) + (int)(0.2 * g) + (int)(0.1 * b)); tmp.SetPixel(i, j, Color.FromArgb(Result, Result, Result)); } this.pictureBox2.Image = tmp;