public class CircularShutterEffect : ShaderEffect
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
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:\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 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:\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