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>
时间: 2024-10-28 20:45:53