←Select platform

BrightExtractEffect Class

Summary
Adjust the image brightness based on the given threshold.
Syntax
C#
VB
C++
public class BrightExtractEffect : ShaderEffect 
  
Public Class BrightExtractEffect  
   Inherits System.Windows.Media.Effects.ShaderEffect 
   Implements System.Windows.Media.Animation.IAnimatable  
public ref class BrightExtractEffect : public System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatable   
Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.Windows.Controls; 
using Leadtools.Windows.Media; 
using Leadtools.Windows.Media.Effects; 
 
class BrightExtractEffectExampleWindow : Window 
{ 
   public BrightExtractEffectExampleWindow() 
   { 
      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 slider 
      TextBlock tb = new TextBlock(); 
      tb.HorizontalAlignment = HorizontalAlignment.Center; 
      tb.Text = "Threshold:"; 
      sp.Children.Add(tb); 
 
      Slider theSlider = new Slider(); 
      theSlider.Minimum = -1.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 viewer 
      theViewer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg"))); 
 
      // Create the effect 
      BrightExtractEffect effect = new BrightExtractEffect(); 
      effect.Threshold = 0.7; 
      theViewer.ImageEffect = effect; 
 
      // Bind the properties 
      Binding bind = new Binding(); 
      bind.Source = effect; 
      bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; 
      bind.Path = new PropertyPath("Threshold"); 
      theSlider.SetBinding(Slider.ValueProperty, bind); 
 
      Title = "Using BrightExtractEffect"; 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.Windows.Controls 
Imports Leadtools.Windows.Media 
Imports Leadtools.Windows.Media.Effects 
 
Class BrightExtractEffectExampleWindow 
   Inherits Window 
   Public Sub New() 
      Dim sp As New StackPanel() 
      Content = sp 
 
      Dim theViewer As New ImageViewer() 
 
      theViewer.HorizontalAlignment = HorizontalAlignment.Center 
      theViewer.VerticalAlignment = VerticalAlignment.Top 
      theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left 
      theViewer.ImageVerticalAlignment = VerticalAlignment.Top 
 
      sp.Children.Add(theViewer) 
 
      ' Create the slider 
      Dim tb As New TextBlock() 
      tb.HorizontalAlignment = HorizontalAlignment.Center 
      tb.Text = "Threshold:" 
      sp.Children.Add(tb) 
 
      Dim theSlider As New Slider() 
      theSlider.Minimum = -1.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 viewer 
      theViewer.Source = New BitmapImage(New Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg"))) 
 
      ' Create the effect 
      Dim effect As New BrightExtractEffect() 
      effect.Threshold = 0.7 
      theViewer.ImageEffect = effect 
 
      ' Bind the properties 
      Dim bind As New Binding() 
      bind.Source = effect 
      bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged 
      bind.Path = New PropertyPath("Threshold") 
      theSlider.SetBinding(Slider.ValueProperty, bind) 
 
      Title = "Using BrightExtractEffect" 
   End Sub 
End Class 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.Media.Effects Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.