for (int y = 0; y < bmp.Height; y++){ for (int x = 0; x < bmp.Width; x++){ if (data[y * bmpData.Stride + x * 3] == Color.White.B){ data[y * bmpData.Stride + x * 3] = Color.Black.B; } } }
2.変数を使う場合
int w = bmp.Width; int h = bmp.Height; int yPos; byte white = Color.White.B; byte black = Color.Black.B;
for (int y = 0; y < h; y++){ yPos = y * bmpData.Stride; for (int x = 0; x < w; x++){ if (data[yPos + x * 3] == white){ data[yPos + x * 3] = black; } } }