前台:
<Image Name="myImg" Source="..\Themes\img.png"></Image>
后台:
ImageSource isource = myImg.Source; FormatConvertedBitmap fcb = new FormatConvertedBitmap((BitmapSource)isource, PixelFormats.Gray32Float, null, 0); myImg.Source = fcb; myImg.OpacityMask = new ImageBrush(isource);
参考资料:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/1961fcab-14f4-4345-87b2-dd2bc517898c/
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.formatconvertedbitmap.aspx
http://msdn.microsoft.com/zh-cn/library/system.windows.media.drawinggroup.opacitymask.aspx
本文介绍如何使用 WPF (Windows Presentation Foundation) 进行图像的灰度转换,并应用图像作为控件的透明度遮罩效果。通过 FormatConvertedBitmap 类实现图像的灰度显示,并利用 ImageBrush 设置前台控件的 OpacityMask 属性来达到透明度遮罩的效果。
1116

被折叠的 条评论
为什么被折叠?



