图像的反色处理
反色的实际含义是将R、G、B值反转,如果颜色的量化级是256,则用255分别减去R、G、B的值作为新图的颜色。
public Bitmap ReColor(Image image) { int width = image.Width; int height = image.Height; Bitmap bitmap = (Bitmap)image; Bitmap temp = new Bitmap( width, height ); Color pixel; int r, g, b; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { pixel = bitmap.GetPixel( x, y ); r = 255 - pixel.R; g = 255 - pixel.G; b = 255 - pixel.B; temp.SetPixel( x, y, Color.FromArgb( r, g, b ) ); } } return temp; }