![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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;