Leadtools.Windows.Media.Effects Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.02.15
SampleTargetCommandBitmapEffect Class
See Also  Members   Example 
Leadtools.Windows.Media.Effects.Color Namespace : SampleTargetCommandBitmapEffect Class





Corrects color values by shifting the sample colors to the target colors.

Syntax

Visual Basic (Declaration) 
Public Class SampleTargetCommandBitmapEffect 
   Inherits RasterCommandBitmapEffect
Visual Basic (Usage)Copy Code
Dim instance As SampleTargetCommandBitmapEffect
C# 
public class SampleTargetCommandBitmapEffect : RasterCommandBitmapEffect 
Managed Extensions for C++ 
public __gc class SampleTargetCommandBitmapEffect : public RasterCommandBitmapEffect 
C++/CLI 
public ref class SampleTargetCommandBitmapEffect : public RasterCommandBitmapEffect 
XAML Property Element Usage 

SampleTargetCommandBitmapEffect ...

Example

Run the SampleTargetCommandBitmapEffect on an image.

Visual BasicCopy Code
Public Sub SampleTargetCommandBitmapEffectExample(ByVal element As FrameworkElement)
   Dim effect As SampleTargetCommandBitmapEffect = New SampleTargetCommandBitmapEffect()
   effect.Flags = SampleTargetCommandBitmapEffectsFlags.Red Or SampleTargetCommandBitmapEffectsFlags.High
   effect.SampleColor = Color.FromRgb(0, 0, 255)
   effect.TargetColor = Color.FromRgb(0, 255, 0)
   element.BitmapEffect = effect

   Dim storyboard As Storyboard = New Storyboard()

   Dim animation1 As ColorAnimation = New ColorAnimation()
   animation1.From = Color.FromRgb(0, 0, 0)
   animation1.To = Color.FromRgb(255, 255, 255)
   animation1.Duration = New Duration(TimeSpan.Parse("0:0:5"))
   animation1.RepeatBehavior = RepeatBehavior.Forever
   animation1.AutoReverse = False

   storyboard.SetTargetName(animation1, "AnimatedBitmapEffect")
   storyboard.SetTargetProperty(animation1, New PropertyPath(SampleTargetCommandBitmapEffect.SampleColorProperty))
   element.RegisterName("AnimatedBitmapEffect", effect)
   storyboard.Children.Add(animation1)

   Dim animation2 As ColorAnimation = New ColorAnimation()
   animation2.From = Color.FromRgb(255, 255, 255)
   animation2.To = Color.FromRgb(0, 0, 0)
   animation2.Duration = New Duration(TimeSpan.Parse("0:0:5"))
   animation2.RepeatBehavior = RepeatBehavior.Forever
   animation2.AutoReverse = False

   storyboard.SetTargetName(animation2, "AnimatedBitmapEffect")
   storyboard.SetTargetProperty(animation2, New PropertyPath(SampleTargetCommandBitmapEffect.TargetColorProperty))
   element.RegisterName("AnimatedBitmapEffect", effect)
   storyboard.Children.Add(animation2)

   storyboard.Begin(element)
End Sub
C#Copy Code
public void SampleTargetCommandBitmapEffectExample(FrameworkElement element) 

   SampleTargetCommandBitmapEffect effect = new SampleTargetCommandBitmapEffect(); 
   effect.Flags = SampleTargetCommandBitmapEffectsFlags.Red | SampleTargetCommandBitmapEffectsFlags.High; 
   effect.SampleColor = Color.FromRgb(0, 0, 255); 
   effect.TargetColor = Color.FromRgb(0, 255, 0); 
   element.BitmapEffect = effect; 
 
   Storyboard storyboard = new Storyboard(); 
 
   ColorAnimation animation1 = new ColorAnimation(); 
   animation1.From = Color.FromRgb(0, 0, 0); 
   animation1.To = Color.FromRgb(255, 255, 255); 
   animation1.Duration = new Duration(TimeSpan.Parse("0:0:5")); 
   animation1.RepeatBehavior = RepeatBehavior.Forever; 
   animation1.AutoReverse = false; 
 
   Storyboard.SetTargetName(animation1, "AnimatedBitmapEffect"); 
   Storyboard.SetTargetProperty(animation1, new PropertyPath(SampleTargetCommandBitmapEffect.SampleColorProperty)); 
   element.RegisterName("AnimatedBitmapEffect", effect); 
   storyboard.Children.Add(animation1); 
 
   ColorAnimation animation2 = new ColorAnimation(); 
   animation2.From = Color.FromRgb(255, 255, 255); 
   animation2.To = Color.FromRgb(0, 0, 0); 
   animation2.Duration = new Duration(TimeSpan.Parse("0:0:5")); 
   animation2.RepeatBehavior = RepeatBehavior.Forever; 
   animation2.AutoReverse = false; 
 
   Storyboard.SetTargetName(animation2, "AnimatedBitmapEffect"); 
   Storyboard.SetTargetProperty(animation2, new PropertyPath(SampleTargetCommandBitmapEffect.TargetColorProperty)); 
   element.RegisterName("AnimatedBitmapEffect", effect); 
   storyboard.Children.Add(animation2); 
 
   storyboard.Begin(element); 
}
XAMLCopy Code
<Page Title="CSAnimateEffect" Height="391" Width="300" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:lteffects="clr-namespace:Leadtools.Windows.Media.Effects.Color;assembly=Leadtools.Windows.Media.Effects"> 
  <Grid> 
    <Image Margin="10,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Center" Source="C:\Program Files\LEAD Technologies, Inc\LEADTOOLS 15\Images\slave.jpg"> 
      <Image.BitmapEffect> 
        <lteffects:SampleTargetCommandBitmapEffect x:Name="AnimatedBitmapEffect" Flags="High, Blue" SampleColor="Blue" TargetColor="Green" /> 
      </Image.BitmapEffect> 
      <Image.Triggers> 
        <EventTrigger RoutedEvent="Image.Loaded"> 
          <BeginStoryboard> 
            <Storyboard> 
              <ColorAnimation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="SampleColor" From="Black" To="White" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="false" /> 
              <ColorAnimation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="TargetColor" From="White" To="Black" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="false" /> 
            </Storyboard> 
          </BeginStoryboard> 
        </EventTrigger> 
      </Image.Triggers> 
    </Image> 
  </Grid> 
</Page>

Remarks

  • For example, suppose you are working with a color image. In the SampleColor property or the sampleColor parameter, set the red value portion of the Color structure to 125, the green portion to 165 and the blue portion to 100. In the TargetColor property or the targetColor parameter you set the red value portion to 170, the green to 120 and the blue to 200. If you set SampleTargetCommandBitmapEffectsFlags.Blue in the Flags property or the flags parameter, then for every pixel in the image that has a blue value of 100, that blue value will be changed to 200, thus shifting the colors in the image. Depending on whether you set SampleTargetCommandBitmapEffectsFlags.Low, SampleTargetCommandBitmapEffectsFlags.Mid, or SampleTargetCommandBitmapEffectsFlags.High, either the shadow values in the blue channel will be remapped, or the midtone values in the blue channel will be remapped, or the highlight values in the blue channel will be remapped.
  • For grayscale images the gray value of the SampleColor and TargetColor properties or the sampleColor and targetColor parameters are used, and the different channel flags have the same effect since it works on the same channel (gray channel). Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in all LEADTOOLS Document and Medical Imaging toolkits.
  • This command does not support signed data images.

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Freezable
            System.Windows.Media.Animation.Animatable
               System.Windows.Media.Effects.BitmapEffect
                  Leadtools.Windows.Media.Effects.RasterCommandBitmapEffect
                     Leadtools.Windows.Media.Effects.Color.SampleTargetCommandBitmapEffect

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003

See Also