How to convert Parallel.For to PLINQ
问题 Parallel.For(0, Height, new ParallelOptions { MaxDegreeOfParallelism = 6 }, y => { int currentLine = y * BMPData.Stride; for (int x = 0; x < Width; x = x + BPX) { var b = pixels[currentLine + x]; var g = pixels[currentLine + x + 1]; var r = pixels[currentLine + x + 2]; int avg = (r + g + b) / 3; pixels[currentLine + x] = (byte)avg; pixels[currentLine + x + 1] = (byte)avg; pixels[currentLine + x + 2] = (byte)avg; } }); This is basically a parallel code where it turns bitmap data pixels into