图像处理-06-图像的反色处理_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > 图像处理-06-图像的反色处理

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

 2013/11/4 12:35:57  种花生的读书人  博客园  我要评论(0)
  • 摘要:图像的反色处理反色的实际含义是将R、G、B值反转,如果颜色的量化级是256,则用255分别减去R、G、B的值作为新图的颜色。publicBitmapReColor(Imageimage){intwidth=image.Width;intheight=image.Height;Bitmapbitmap=(Bitmap)image;Bitmaptemp=newBitmap(width,height);Colorpixel;intr,g,b;for(intx=0;x<width;x++)
  • 标签:图像处理

class="title">图像的反色处理

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

 

发表评论
用户名: 匿名