private void pixel_Click(object sender, EventArgs e) { if (curBitmap != null) { BitmapByHandle = (Bitmap)curBitmap.Clone(); myTimer.ClearTimer(); myTimer.Start(); Color curColor; int ret; for (int i = 0; i < BitmapByHandle.Width; i++) { for (int j = 0; j < BitmapByHandle.Height; j++) { curColor = BitmapByHandle.GetPixel(i, j); ret = (int)(curColor.R * 0.299 + curColor.G * 0.587 + curColor.B * 0.114); BitmapByHandle.SetPixel(i, j, Color.FromArgb(ret, ret, ret)); } } myTimer.Stop(); timeBox.Text = myTimer.Duration.ToString("####.##") + " 毫秒"; Invalidate(); } }