Leadtools.Windows.Media.Effects Send comments on this topic. | Back to Introduction - LEADTOOLS WPF | Help Version 16.5.9.25
GrayScaleToDuotoneCommandBitmapEffect Class
See Also  Members   Example 
Leadtools.Windows.Media.Effects.Color Namespace : GrayScaleToDuotoneCommandBitmapEffect Class





Converts the grayscale image into a colored one by mixing or replacing the original values of the pixels with new colors.

Syntax

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

GrayScaleToDuotoneCommandBitmapEffect ...

XAML Property Element Usage 

GrayScaleToDuotoneCommandBitmapEffect ...

Example

Run the GrayScaleToDuotoneCommandBitmapEffect on an image.

Visual BasicCopy Code
Public Sub GrayScaleToDuotoneCommandBitmapEffectExample(ByVal element As FrameworkElement)
   ' Initialize Effect
   Dim effect As GrayScaleToDuotoneCommandBitmapEffect = New GrayScaleToDuotoneCommandBitmapEffect()
   effect.Color = Color.FromRgb(255, 0, 0)
   element.BitmapEffect = effect
End Sub
C#Copy Code
public void GrayScaleToDuotoneCommandBitmapEffectExample(FrameworkElement element) 

   // Initialize Effect 
   GrayScaleToDuotoneCommandBitmapEffect effect = new GrayScaleToDuotoneCommandBitmapEffect(); 
   effect.Color =  System.Windows.Media.Color.FromRgb(255, 0, 0); 
   element.BitmapEffect = effect; 
 
}
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 16\Images\slave.jpg"> 
      <Image.BitmapEffect> 
        <lteffects:GrayScaleToDuotoneCommandBitmapEffect x:Name="MyBitmapEffect" /> 
      </Image.BitmapEffect> 
    </Image> 
  </Grid> 
</Page>

Remarks

  • This class was designed for use with grayscale images. If the image being used is not grayscale, this method only affects those pixels or areas of the image where Red = Green = Blue.
  • This class transforms the 8-bit grayscale images into colored 8-bit images (Palette) meanwhile the 12-bit and 16-bit grayscale images are transformed into a 48-bit colored image.
  • Monotone conversion is possible by setting GrayScaleToDuotoneCommandBitmapEffectsMixingType to ReplaceOldWithNew, which clears the palette.
  • This method gives you the option of having the toolkit generate the array of colors to use or creating the array of colors to use yourself.
  • To have the toolkit generate the array of colors, pass the color to use for generating the array of gradient colors in the Color property.
    • If the image is grayscale (not binary) the GrayScaleToDuotoneCommandBitmapEffect will use the color set in the GrayScaleToDuotoneCommandBitmapEffect.Color property and generate a 256 color gradient in NewColor.
    • If the image is not grayscale (it is color) then the GrayScaleToDuotoneCommandBitmapEffect will use the color set in the GrayScaleToDuotoneCommandBitmapEffect.Color property and generate a 256 color gradient in NewColor. These colors will be used to change only those pixels in the color image for which Red = Green = Blue.
  • To use a user-defined array of colors:
  • 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.GrayScaleToDuotoneCommandBitmapEffect

Requirements

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

See Also