BitmapData bitmapdata = bitmap.LockBits ( new Rectangle( 0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb ); IntPtr ptr = bitmapdata.Scan0; // declare an array to hold // the bytes of bitmap int bytes = Math.Abs ( bitmapdata.Stride ) * bitmap.Height; byte [ ] values = new byte [ bytes ]; System.Runtime.InteropServices.Marshal.Copy ( ptr, values, 0, bytes ); for ( int i = 0; ( i < values.Length ); i += 3 ) { // Comparing blue and green and // blue and red. if blue is greater // than both pixel than make it // more intensive otherwise make white if ( ( values [ i ] - values [ i + 1 ] > 9 ) && ( values [ i ] - values [ i + 2 ] > 9 ) { values [ i ] = 255; values [ i + 1 ] = 0; values [ i + 2 ] = 0; } else { values [ i ] = 255; values [ i + 1 ] = 255; values [ i + 2 ] = 255; } } bitmap.Save("bitmap.jpg");
PixelFormat
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)