public class DesaturateEffect : ShaderEffect Public Class DesaturateEffectInherits System.Windows.Media.Effects.ShaderEffectImplements System.Windows.Media.Animation.IAnimatable
public ref class DesaturateEffect : public System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatable Negative values decrease the saturation of colors. Positive values increase the saturation. The saturation level is increased or decreased by a percentage of its present saturation level. For example, an increase of 20 of the current saturation level "L" will raise the new saturation level "L1" to a value L + 0.20 * L. Likewise, increasing the saturation level 100 doubles the saturation level ( L1 = L + 1.0 * L). Decreasing the saturation level 100 will set the new saturation level to 0. This process is carried out for every pixel.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.Windows.Controls;using Leadtools.Windows.Media;using Leadtools.Windows.Media.Effects;class DesaturateEffectExampleWindow : Window{public DesaturateEffectExampleWindow(){StackPanel sp = new StackPanel();Content = sp;ImageViewer theViewer = new ImageViewer();theViewer.HorizontalAlignment = HorizontalAlignment.Center;theViewer.VerticalAlignment = VerticalAlignment.Top;theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;theViewer.ImageVerticalAlignment = VerticalAlignment.Top;sp.Children.Add(theViewer);// Create the slidersTextBlock tb = new TextBlock();tb.HorizontalAlignment = HorizontalAlignment.Center;tb.Text = "Saturation:";sp.Children.Add(tb);Slider theSlider = new Slider();theSlider.Minimum = 0.0;theSlider.Maximum = 1.0;theSlider.Width = 400;theSlider.Orientation = Orientation.Horizontal;theSlider.IsSnapToTickEnabled = true;theSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;theSlider.TickFrequency = 0.1;theSlider.AutoToolTipPrecision = 2;theSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRight;sp.Children.Add(theSlider);// Load an image into the viewertheViewer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")));// Create the effectDesaturateEffect effect = new DesaturateEffect();effect.Saturation = 0.5;theViewer.ImageEffect = effect;// Bind the propertiesBinding bind = new Binding();bind.Source = effect;bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;bind.Path = new PropertyPath("Saturation");theSlider.SetBinding(Slider.ValueProperty, bind);Title = "Using DesaturateEffect";}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.Windows.ControlsImports Leadtools.Windows.MediaImports Leadtools.Windows.Media.EffectsClass DesaturateEffectExampleWindowInherits WindowPublic Sub New()Dim sp As New StackPanel()Content = spDim theViewer As New ImageViewer()theViewer.HorizontalAlignment = HorizontalAlignment.CentertheViewer.VerticalAlignment = VerticalAlignment.ToptheViewer.ImageHorizontalAlignment = HorizontalAlignment.LefttheViewer.ImageVerticalAlignment = VerticalAlignment.Topsp.Children.Add(theViewer)' Create the slidersDim tb As New TextBlock()tb.HorizontalAlignment = HorizontalAlignment.Centertb.Text = "Saturation:"sp.Children.Add(tb)Dim theSlider As New Slider()theSlider.Minimum = 0.0theSlider.Maximum = 1.0theSlider.Width = 400theSlider.Orientation = Orientation.HorizontaltheSlider.IsSnapToTickEnabled = TruetheSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRighttheSlider.TickFrequency = 0.1theSlider.AutoToolTipPrecision = 2theSlider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRightsp.Children.Add(theSlider)' Load an image into the viewertheViewer.Source = New BitmapImage(New Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")))' Create the effectDim effect As New DesaturateEffect()effect.Saturation = 0.5theViewer.ImageEffect = effect' Bind the propertiesDim bind As New Binding()bind.Source = effectbind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChangedbind.Path = New PropertyPath("Saturation")theSlider.SetBinding(Slider.ValueProperty, bind)Title = "Using DesaturateEffect"End SubEnd ClassPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
