LEADTOOLS WPF and Silverlight (Leadtools.Windows.Media.Effects assembly)
LEAD Technologies, Inc

SharpenEffect Class

Example 





Members 
Increases or decreases the sharpness of this image. .NET support Silverlight support
Object Model
SharpenEffect Class
Syntax
'Declaration
 
Public Class SharpenEffect 
   Inherits System.Windows.Media.Effects.ShaderEffect
   Implements System.Windows.Media.Animation.IAnimatable 
'Usage
 
Dim instance As SharpenEffect
ObjectiveC Syntax
Java Syntax
Remarks

Negative sharpness values decrease the sharpness of the image. Specify -1000 for minimum sharpness. Positive sharpness values increase the sharpness. Specify +1000 for maximum sharpness.

Example
Copy CodeCopy Code  
Class SharpenEffectExampleWindow
      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 sliders
         Dim tb As New TextBlock()
         tb.HorizontalAlignment = HorizontalAlignment.Center
         tb.Text = "Amount:"
         sp.Children.Add(tb)

         Dim theSlider As New Slider()
         theSlider.Minimum = -10.0
         theSlider.Maximum = 10.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 SharpenEffect()
         effect.Amount = 1.0
         theViewer.ImageEffect = effect

         ' Bind the properties
         Dim bind As New Binding()
         bind.Source = effect
         bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
         bind.Path = New PropertyPath("Amount")
         theSlider.SetBinding(Slider.ValueProperty, bind)

         Title = "Using SharpenEffect"
      End Sub
   End Class

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
class SharpenEffectExampleWindow : Window
   {
      public SharpenEffectExampleWindow()
      {
         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 sliders
         TextBlock tb = new TextBlock();
         tb.HorizontalAlignment = HorizontalAlignment.Center;
         tb.Text = "Amount:";
         sp.Children.Add(tb);

         Slider theSlider = new Slider();
         theSlider.Minimum = -10.0;
         theSlider.Maximum = 10.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
         SharpenEffect effect = new SharpenEffect();
         effect.Amount = 1.0;
         theViewer.ImageEffect = effect;

         // Bind the properties
         Binding bind = new Binding();
         bind.Source = effect;
         bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
         bind.Path = new PropertyPath("Amount");
         theSlider.SetBinding(Slider.ValueProperty, bind);

         Title = "Using SharpenEffect";
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
class SharpenEffectExampleWindow : UserControl
{
   public SharpenEffectExampleWindow()
   {
      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 sliders
      TextBlock tb = new TextBlock();
      tb.HorizontalAlignment = HorizontalAlignment.Center;
      tb.Text = "Amount:";
      sp.Children.Add(tb);

      Slider theSlider = new Slider();
      theSlider.Minimum = -10.0;
      theSlider.Maximum = 10.0;
      theSlider.Width = 400;
      theSlider.Orientation = Orientation.Horizontal;

      sp.Children.Add(theSlider);

      // Load an image into the viewer
      theViewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Cannon.jpg"));

      // Create the effect
      SharpenEffect effect = new SharpenEffect();
      effect.Amount = 1.0;
      theViewer.ImageEffect = effect;

      // Bind the properties
      Binding bind = new Binding();
      bind.Source = effect;
      bind.UpdateSourceTrigger = UpdateSourceTrigger.Default;
      bind.Path = new PropertyPath("Amount");
      theSlider.SetBinding(Slider.ValueProperty, bind);
   }
}
Class SharpenEffectExampleWindow
   Inherits UserControl
   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 sliders
      Dim tb As New TextBlock()
      tb.HorizontalAlignment = HorizontalAlignment.Center
      tb.Text = "Amount:"
      sp.Children.Add(tb)

      Dim theSlider As New Slider()
      theSlider.Minimum = -10.0
      theSlider.Maximum = 10.0
      theSlider.Width = 400
      theSlider.Orientation = Orientation.Horizontal

      sp.Children.Add(theSlider)

      ' Load an image into the viewer
      theViewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Cannon.jpg"))

      ' Create the effect
      Dim effect As New SharpenEffect()
      effect.Amount = 1.0
      theViewer.ImageEffect = effect

      ' Bind the properties
      Dim bind As New Binding()
      bind.Source = effect
      bind.UpdateSourceTrigger = UpdateSourceTrigger.Default
      bind.Path = New PropertyPath("Amount")
      theSlider.SetBinding(Slider.ValueProperty, bind)
   End Sub
End Class
<Window x:Class="SharpenEffectExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:leadControls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"
xmlns:leadEffects="clr-namespace:Leadtools.Windows.Media.Effects;assembly=Leadtools.Windows.Media.Effects"
Height="600" Width="800">
   <StackPanel>
      <leadControls:ImageViewer
            HorizontalAlignment="Center" VerticalAlignment="Top"
            ImageHorizontalAlignment="Left" ImageVerticalAlignment="Top"
            Source="file:///c:\users\Public\Documents\LEADTOOLS Images\cannon.jpg">
         <leadControls:ImageViewer.ImageEffect>
            <leadEffects:SharpenEffect
               Amount="{Binding Value, ElementName=AmountSlider, UpdateSourceTrigger=PropertyChanged}">
            </leadEffects:SharpenEffect>
         </leadControls:ImageViewer.ImageEffect>
      </leadControls:ImageViewer>
      <TextBlock HorizontalAlignment="Center" Text="Amount:"/>
      <Slider x:Name="AmountSlider"
            Minimum="-10.0" Maximum="10.0" TickFrequency="0.1"
            Width="400" Orientation="Horizontal"
            IsSnapToTickEnabled="True" TickPlacement="BottomRight"
            AutoToolTipPrecision="2" AutoToolTipPlacement="BottomRight">
      </Slider>
   </StackPanel>
</Window>
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SharpenEffect Members
Leadtools.Windows.Media.Effects Namespace
Introduction

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.