WPF_图片黑白处理

 1    BitmapImage myBitmapImage = new BitmapImage ( );
 2             myBitmapImage . BeginInit ( );
 3             myBitmapImage . UriSource = new Uri ( ImagePath , UriKind . Relative );
 4             myBitmapImage . DecodePixelWidth = 200;
 5             myBitmapImage . EndInit ( );
 6             FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap ( );
 7             newFormatedBitmapSource . BeginInit ( );
 8             newFormatedBitmapSource . Source = myBitmapImage;
 9             newFormatedBitmapSource . DestinationFormat = PixelFormats . Gray32Float;
10             newFormatedBitmapSource . EndInit ( );
11             Image myImage = new Image ( );
12             myImage . Width = 200;
13             //set image source
14             myImage . Source = newFormatedBitmapSource;
View Code

 

posted @ 2015-08-05 19:53  gopher-lin  阅读(699)  评论(0)    收藏  举报