public static void ChangeColor(Bitmap src, Color color, IEnumerable<Pixel> changedPixels) { var lockBitmap = new LockBitmap(src); lockBitmap.LockBits(); foreach (var changedPixel in changedPixels) { lockBitmap.SetPixel(changedPixel.X, changedPixel.Y, color); } lockBitmap.UnlockBits(); }
public static Bitmap ChangeColor(Bitmap src, Color color) { var result = new Bitmap(src); var lockBitmap = new LockBitmap(result); lockBitmap.LockBits(); var compareClr = Color.FromArgb(255, 255, 255, 255); for (var y = 0; y < lockBitmap.Height; y++) { for (var x = 0; x < lockBitmap.Width; x++) { if (lockBitmap.GetPixel(x, y) == compareClr) { lockBitmap.SetPixel(x, y, color); } } } lockBitmap.UnlockBits(); return result; }