wpf,图片灰化处理

 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-08-29 16:41:18

wpf,图片灰化处理的相关文章

WPF 图片浏览 伪3D效果

原文:WPF 图片浏览 伪3D效果 首先上效果图: 因项目要求,需要把图片以"好看"."炫"的效果展示出来,特地研究了一下WPF关于3D方面的制作,奈何最终成果只是能够画出一个立方体并使之旋转. 项目时间仅剩两天,只好放弃3D另找出路,于是就想起了Flash中各种"炫丽"的动画效果,图片按椭圆排列,并且旋转. 于是开始代码,然后发现关于椭圆啊.正玄余玄.x,y,r等等数学知识都忘得光光了,仅有思路没有进展,无奈之下开始百度恶补数学知识.图形变换.

WPF图片,DataGrid等实现圆角

原文:WPF图片,DataGrid等实现圆角 <Grid HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> </Grid.RowDefinitions> <Grid Grid.Ro

WPF 图片抗锯齿,尤其是小图片更为严重

原文:WPF 图片抗锯齿,尤其是小图片更为严重 UseLayoutRounding="True" 搞定,就是这么给力,分享给大家 原文地址:https://www.cnblogs.com/lonelyxmas/p/12034563.html

【转】【WPF】wpf 图片指针处理

我一直用GDI+做Winform 的基于指针的图片处理,这次下决心全部移到wpf上(主要是显示布局很方便)采用的图片是2512*3307 的大图 830万像素类库基于WritableBitmapEx 的wpf版本函数是我自己写的扩展方法,只是利用了 writableBitmapEx提供的环境 ,我懒得从头到尾自己写了 1.标准int32数组遍历计算 release0.28s public unsafe static void TestGray1(WriteableBitmap bmp) { us

WPF图片拖拉变形、合成

使用WPF的装饰器(Adorner)实现图片拖拉变形,DrawingVisual高保真合成图片.效果如下: 源码:https://gitee.com/orchis/ImageFotoMix.git 原文地址:https://www.cnblogs.com/edwardorchis/p/10260653.html

wpf 图片框image 显示byte[] 类型的图片

HttpItem item = new HttpItem(); HttpHelper http = new HttpHelper(); item.URL = "http://das.app.easypass.cn/Price/VerifyCode.aspx"; item.ResultType = ResultType.Byte; HttpResult result = http.GetHtml(item); // result.ResultByte; BitmapImage bmi=n

WPF图片模糊之解决方案

<Style TargetType="{x:Type Image}"> <Setter Property="RenderOptions.BitmapScalingMode" Value="NearestNeighbor"/> <Setter Property="UseLayoutRounding" Value="true"/> </Style>

WPF 图片跑马灯

1 public void OnFlushImage() 2 { 3 bool bStart = false; 4 while (mFlush == true) 5 { 6 if (bStart) 7 { 8 Thread.Sleep(1000); 9 continue; 10 } 11 12 bStart = true; 13 14 cloudTop.Dispatcher.BeginInvoke( 15 new Action(() => 16 { 17 Duration duration =

Android bitmap图片处理

一.View转换为Bitmap 在Android中所有的控件都是View的直接子类或者间接子类,通过它们可以组成丰富的UI界面.在窗口显示的时候Android会把这些控件都加载到内存中,形成一个以ViewRoot为根节点的控件树,然后由根节点开始逐级把控件绘制到屏幕上. 可以通过调用控件的setDrawingCacheEnabled(true)方法,开启绘图缓存功能,在绘制View的时候把图像缓存起来,然后通过getDrawingCache()方法获取这个缓存的Bitmap.需要注意的是,当不再