private BitmapSource ToGray(BitmapSource source)
{
FormatConvertedBitmap re = new FormatConvertedBitmap();
re.BeginInit();
re.Source = source;
re.DestinationFormat = PixelFormats.Gray8;
re.EndInit();
return re;
}
<Image HorizontalAlignment="Center" Width="30" Height="30" VerticalAlignment="Center" Stretch="None" Margin="0">
<Image.Source>
<FormatConvertedBitmap DestinationFormat="Gray8">
<FormatConvertedBitmap.Source>
<BitmapImage UriSource="/课本.png" />
</FormatConvertedBitmap.Source>
</FormatConvertedBitmap>
</Image.Source>
<Image.OpacityMask>
<ImageBrush>
<ImageBrush.ImageSource>
<BitmapImage UriSource="/课本.png" />
</ImageBrush.ImageSource>
</ImageBrush>
</Image.OpacityMask>
</Image>
xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" <Image Margin="0,0,0,49" Source="page2.png" Stretch="None"> <Image.Effect> <ee:MonochromeEffect/> </Image.Effect> </Image>