←Select platform

InvertEffect Class

Inverts the colors in the specified image, giving it the appearance of a photographic negative.
public class InvertEffect : ShaderEffect 
Public Class InvertEffect  
   Inherits System.Windows.Media.Effects.ShaderEffect 
   Implements System.Windows.Media.Animation.IAnimatable  
public ref class InvertEffect : public System.Windows.Media.Effects.ShaderEffect, System.Windows.Media.Animation.IAnimatable   

This class can also be used to invert the color of a 1-bit image, making the black white and the white black.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.Windows.Controls; 
using Leadtools.Windows.Media; 
using Leadtools.Windows.Media.Effects; 
class InvertEffectExampleWindow : Window 
   private ImageViewer theViewer; 
   public InvertEffectExampleWindow() 
      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; 
      // Load an image into the viewer 
      theViewer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg"))); 
      Title = "Double click to use the Effect"; 
      theViewer.MouseDoubleClick += new MouseButtonEventHandler(theViewer_MouseDoubleClick); 
   private void theViewer_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
      InvertEffect effect = new InvertEffect(); 
      theViewer.ImageEffect = effect; 
      Title = "Using InvertEffect"; 
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 InvertEffectExampleWindow 
   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 
      ' Load an image into the viewer 
      theViewer.Source = New BitmapImage(New Uri(System.IO.Path.Combine(LEAD_VARS.ImagesDir, "Cannon.jpg"))) 
      Title = "Double click to use the Effect" 
      AddHandler theViewer.MouseDoubleClick, AddressOf theViewer_MouseDoubleClick 
   End Sub 
   Private Sub theViewer_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs) 
      Dim effect As New InvertEffect() 
      theViewer.ImageEffect = effect 
      Title = "Using InvertEffect" 
   End Sub 
End Class 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 

Target Platforms

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

Leadtools.Windows.Media.Effects Assembly