C#
VB
C++
Creates a rectangular shutter effect by using a center point, shutter size and a color to clear the area outside the shutter.
public class RectangularShutterEffect : ShaderEffect Public Class RectangularShutterEffectInherits System.Windows.Media.Effects.ShaderEffectImplements System.Windows.Media.Animation.IAnimatable
public ref class RectangularShutterEffect : public System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatable
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.Windows.Controls;using Leadtools.Windows.Media;using Leadtools.Windows.Media.Effects;class RectangularShutterEffectExampleWindow : Window{private ImageViewer theViewer;public RectangularShutterEffectExampleWindow(){StackPanel sp = new StackPanel();Content = sp;theViewer = new ImageViewer();theViewer.HorizontalAlignment = HorizontalAlignment.Center;theViewer.VerticalAlignment = VerticalAlignment.Top;theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;theViewer.ImageVerticalAlignment = VerticalAlignment.Top;sp.Children.Add(theViewer);// Load an image into the viewertheViewer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")));Title = "RectangularShutterEffect - Click and and move the mouse cursor on the image to see the effect";theViewer.PreviewMouseDown += new MouseButtonEventHandler(theViewer_PreviewMouseDown);theViewer.MouseMove += new MouseEventHandler(theViewer_MouseMove);theViewer.MouseUp += new MouseButtonEventHandler(theViewer_MouseUp);}private void theViewer_PreviewMouseDown(object sender, MouseButtonEventArgs e){RectangularShutterEffect effect = new RectangularShutterEffect();Point pos = e.GetPosition(theViewer);BitmapSource source = theViewer.Source as BitmapSource;if (source != null){effect.Center = new Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight);effect.Width = 0.125;effect.Height = 0.125;effect.ClearColor = Colors.Blue;theViewer.ImageEffect = effect;}}private void theViewer_MouseMove(object sender, MouseEventArgs e){RectangularShutterEffect effect = theViewer.ImageEffect as RectangularShutterEffect;if (effect != null){Point pos = e.GetPosition(theViewer);BitmapSource source = theViewer.Source as BitmapSource;if (source != null){effect.Center = new Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight);}}}private void theViewer_MouseUp(object sender, MouseButtonEventArgs e){if (theViewer.ImageEffect != null){theViewer.ImageEffect = null;}}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.Windows.ControlsImports Leadtools.Windows.MediaImports Leadtools.Windows.Media.EffectsClass RectangularShutterEffectExampleWindowInherits WindowPrivate theViewer As ImageViewerPublic Sub New()Dim sp As New StackPanel()Content = sptheViewer = New ImageViewer()theViewer.HorizontalAlignment = HorizontalAlignment.CentertheViewer.VerticalAlignment = VerticalAlignment.ToptheViewer.ImageHorizontalAlignment = HorizontalAlignment.LefttheViewer.ImageVerticalAlignment = VerticalAlignment.Topsp.Children.Add(theViewer)' Load an image into the viewertheViewer.Source = New BitmapImage(New Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")))Title = "RectangularShutterEffect - Click and and move the mouse cursor on the image to see the effect"AddHandler theViewer.PreviewMouseDown, AddressOf theViewer_PreviewMouseDownAddHandler theViewer.MouseMove, AddressOf theViewer_MouseMoveAddHandler theViewer.MouseUp, AddressOf theViewer_MouseUpEnd SubPrivate Sub theViewer_PreviewMouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)Dim effect As New RectangularShutterEffect()Dim pos As Point = e.GetPosition(theViewer)Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)If Not source Is Nothing Theneffect.Center = New Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight)effect.Width = 0.125effect.Height = 0.125effect.ClearColor = Colors.BluetheViewer.ImageEffect = effectEnd IfEnd SubPrivate Sub theViewer_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)Dim effect As RectangularShutterEffect = DirectCast(theViewer.ImageEffect, RectangularShutterEffect)If Not effect Is Nothing ThenDim pos As Point = e.GetPosition(theViewer)Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)If Not source Is Nothing Theneffect.Center = New Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight)End IfEnd IfEnd SubPrivate Sub theViewer_MouseUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)If Not theViewer.ImageEffect Is Nothing ThentheViewer.ImageEffect = NothingEnd IfEnd SubEnd ClassPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.Windows.Media;using Leadtools.Windows.Media.Effects;using Leadtools.Windows.Controls;class RectangularShutterEffectExampleWindow : UserControl{private ImageViewer theViewer;public RectangularShutterEffectExampleWindow(){StackPanel sp = new StackPanel();Content = sp;theViewer = new ImageViewer();theViewer.HorizontalAlignment = HorizontalAlignment.Center;theViewer.VerticalAlignment = VerticalAlignment.Top;theViewer.ImageHorizontalAlignment = HorizontalAlignment.Left;theViewer.ImageVerticalAlignment = VerticalAlignment.Top;sp.Children.Add(theViewer);// Load an image into the viewertheViewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Cannon.jpg"));theViewer.MouseMove += new MouseEventHandler(theViewer_MouseMove);}private void theViewer_PreviewMouseDown(object sender, MouseButtonEventArgs e){RectangularShutterEffect effect = new RectangularShutterEffect();Point pos = e.GetPosition(theViewer);BitmapSource source = theViewer.Source as BitmapSource;if (source != null){effect.Center = new Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight);effect.Width = 0.125;effect.Height = 0.125;effect.ClearColor = Colors.Blue;theViewer.ImageEffect = effect;}}private void theViewer_MouseMove(object sender, MouseEventArgs e){RectangularShutterEffect effect = theViewer.ImageEffect as RectangularShutterEffect;if (effect != null){Point pos = e.GetPosition(theViewer);BitmapSource source = theViewer.Source as BitmapSource;if (source != null){effect.Center = new Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight);}}}private void theViewer_MouseUp(object sender, MouseButtonEventArgs e){if (theViewer.ImageEffect != null){theViewer.ImageEffect = null;}}}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.Windows.ControlsImports Leadtools.Windows.MediaImports Leadtools.Windows.Media.EffectsClass RectangularShutterEffectExampleWindowInherits UserControlPrivate theViewer As ImageViewerPublic Sub New()Dim sp As New StackPanel()Content = sptheViewer = New ImageViewer()theViewer.HorizontalAlignment = HorizontalAlignment.CentertheViewer.VerticalAlignment = VerticalAlignment.ToptheViewer.ImageHorizontalAlignment = HorizontalAlignment.LefttheViewer.ImageVerticalAlignment = VerticalAlignment.Topsp.Children.Add(theViewer)' Load an image into the viewertheViewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Cannon.jpg"))AddHandler theViewer.MouseMove, AddressOf theViewer_MouseMoveEnd SubPrivate Sub theViewer_PreviewMouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)Dim effect As New RectangularShutterEffect()Dim pos As Point = e.GetPosition(theViewer)Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)If Not source Is Nothing Theneffect.Center = New Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight)effect.Width = 0.125effect.Height = 0.125effect.ClearColor = Colors.BluetheViewer.ImageEffect = effectEnd IfEnd SubPrivate Sub theViewer_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)Dim effect As RectangularShutterEffect = DirectCast(theViewer.ImageEffect, RectangularShutterEffect)If Not effect Is Nothing ThenDim pos As Point = e.GetPosition(theViewer)Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)If Not source Is Nothing Theneffect.Center = New Point((1.0 * pos.X) / source.PixelWidth,(1.0 * pos.Y) / source.PixelHeight)End IfEnd IfEnd SubPrivate Sub theViewer_MouseUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)If Not theViewer.ImageEffect Is Nothing ThentheViewer.ImageEffect = NothingEnd IfEnd SubEnd Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
