Creates a circular or elliptical shutter effect by using a center point, radius, aspect ratio and a color to clear the area outside the shutter.
public class CircularShutterEffect : System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatable
Public Class CircularShutterEffect
Inherits System.Windows.Media.Effects.ShaderEffect
Implements System.Windows.Media.Animation.IAnimatable
public ref class CircularShutterEffect : public System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatable
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Media
Imports Leadtools.Windows.Media.Effects
Class CircularShutterEffectExampleWindow
Inherits Window
Private theViewer As ImageViewer
Public Sub New()
Dim sp As 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 viewer
theViewer.Source = New BitmapImage(New Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")))
Title = "CircularShutterEffect - Click and and move the mouse cursor on the image to see the effect"
AddHandler theViewer.PreviewMouseDown, AddressOf theViewer_PreviewMouseDown
AddHandler theViewer.MouseMove, AddressOf theViewer_MouseMove
AddHandler theViewer.MouseUp, AddressOf theViewer_MouseUp
End Sub
Private Sub theViewer_PreviewMouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Dim effect As New CircularShutterEffect()
Dim pos As Point = e.GetPosition(theViewer)
Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)
If Not source Is Nothing Then
effect.Center = New Point( _
(1.0 * pos.X) / source.PixelWidth, _
(1.0 * pos.Y) / source.PixelHeight)
effect.Radius = 0.25
effect.AspectRatio = 1.0
effect.ClearColor = Colors.Blue
theViewer.ImageEffect = effect
End If
End Sub
Private Sub theViewer_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim effect As CircularShutterEffect = DirectCast(theViewer.ImageEffect, CircularShutterEffect)
If Not effect Is Nothing Then
Dim pos As Point = e.GetPosition(theViewer)
Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)
If Not source Is Nothing Then
effect.Center = New Point( _
(1.0 * pos.X) / source.PixelWidth, _
(1.0 * pos.Y) / source.PixelHeight)
End If
End If
End Sub
Private Sub theViewer_MouseUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
If Not theViewer.ImageEffect Is Nothing Then
theViewer.ImageEffect = Nothing
End If
End Sub
End Class
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Controls;
using Leadtools.Windows.Media;
using Leadtools.Windows.Media.Effects;
class CircularShutterEffectExampleWindow : Window
{
private ImageViewer theViewer;
public CircularShutterEffectExampleWindow()
{
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 viewer
theViewer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg")));
Title = "CircularShutterEffect - 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)
{
CircularShutterEffect effect = new CircularShutterEffect();
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.Radius = 0.25;
effect.AspectRatio = 1.0;
effect.ClearColor = Colors.Blue;
theViewer.ImageEffect = effect;
}
}
private void theViewer_MouseMove(object sender, MouseEventArgs e)
{
CircularShutterEffect effect = theViewer.ImageEffect as CircularShutterEffect;
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";
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Media;
using Leadtools.Windows.Media.Effects;
using Leadtools.Windows.Controls;
class CircularShutterEffectExampleWindow : UserControl
{
private ImageViewer theViewer;
public CircularShutterEffectExampleWindow()
{
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 viewer
theViewer.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)
{
CircularShutterEffect effect = new CircularShutterEffect();
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.Radius = 0.25;
effect.AspectRatio = 1.0;
effect.ClearColor = Colors.Blue;
theViewer.ImageEffect = effect;
}
}
private void theViewer_MouseMove(object sender, MouseEventArgs e)
{
CircularShutterEffect effect = theViewer.ImageEffect as CircularShutterEffect;
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 Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Media
Imports Leadtools.Windows.Media.Effects
Class CircularShutterEffectExampleWindow
Inherits UserControl
Private theViewer As ImageViewer
Public Sub New()
Dim sp As 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 viewer
theViewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path + "Cannon.jpg"))
AddHandler theViewer.MouseMove, AddressOf theViewer_MouseMove
End Sub
Private Sub theViewer_PreviewMouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Dim effect As New CircularShutterEffect()
Dim pos As Point = e.GetPosition(theViewer)
Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)
If Not source Is Nothing Then
effect.Center = New Point( _
(1.0 * pos.X) / source.PixelWidth, _
(1.0 * pos.Y) / source.PixelHeight)
effect.Radius = 0.25
effect.AspectRatio = 1.0
effect.ClearColor = Colors.Blue
theViewer.ImageEffect = effect
End If
End Sub
Private Sub theViewer_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim effect As CircularShutterEffect = DirectCast(theViewer.ImageEffect, CircularShutterEffect)
If Not effect Is Nothing Then
Dim pos As Point = e.GetPosition(theViewer)
Dim source As BitmapSource = DirectCast(theViewer.Source, BitmapSource)
If Not source Is Nothing Then
effect.Center = New Point( _
(1.0 * pos.X) / source.PixelWidth, _
(1.0 * pos.Y) / source.PixelHeight)
End If
End If
End Sub
Private Sub theViewer_MouseUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
If Not theViewer.ImageEffect Is Nothing Then
theViewer.ImageEffect = Nothing
End If
End Sub
End Class
<Window x:Class="CircularShutterEffectExample"
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:CircularShutterEffect Center="0.5,0.5" Radius="0.25" AspectRatio="1.0" ClearColor="Blue">
</leadEffects:CircularShutterEffect>
</leadControls:ImageViewer.ImageEffect>
</leadControls:ImageViewer>
</StackPanel>
</Window>
Products |
Support |
Feedback: CircularShutterEffect Class - Leadtools.Windows.Media.Effects |
Introduction |
Help Version 19.0.2017.3.21
|
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.