图像的反色处理

反色的实际含义是将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;
        }

 图像处理-06-图像的反色处理

相关文章:

  • 2021-12-20
  • 2021-12-16
  • 2022-12-23
猜你喜欢
  • 2021-06-27
  • 2022-01-07
  • 2021-09-13
  • 2021-08-09
  • 2021-12-11
  • 2022-12-23
  • 2022-02-05
相关资源
相似解决方案