Export (0) Print
Expand All

BitmapEffect Class

Defines a bitmap effect. Derived classes define effects that can be applied to a Visual object, such as a Button or an Image.

Namespace: System.Windows.Media.Effects
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public abstract class BitmapEffect : Animatable
public abstract class BitmapEffect extends Animatable
public abstract class BitmapEffect extends Animatable
This class is abstract; see Inheritance Hierarchy for derived non-abstract classes usable in XAML.

NoteNote:

WPF bitmap effects are software rendered. Any object that applies an effect will also be rendered in software. Bitmap effects should not be applied to large visuals or animations, because this can degrade performance.

Caution noteCaution:

Bitmap effects do not support partial trust execution. An application must have full trust permissions to use bitmap effects.

Scale transforms are applied to a visual before an effect is applied. In the event of a non-uniform scale transform, the effect will use the larger of the scale values.

Updates to the visual tree of a VisualBrush will not propagate if a BitmapEffect is in the brush's parent chain. You can work around this limitation by forcing an update of the scene on the parent object of the effect. You can call InvalidateVisual or include an animation to force a scene update.

Custom effects inherit this class to create a managed interface to the unmanaged effect. For more details on creating custom effect see the Custom BitmapEffect Sample - RGBFilter and the Unmanaged BitmapEffect API.

Notes to Inheritors: CreateUnmanagedEffect must be overridden to initialize an unmanaged effect in managed code. UpdateUnmanagedPropertyState must be overridden when an unmanaged effect has properties that the user can modify. Use this method in conjunction with SetValue to update your unmanaged properties.

This example shows how to use a custom effect in Extensible Application Markup Language (XAML).

Custom effects are created with unmanaged API and create a Component Object Model (COM) dynamic-link library (DLL). To use custom effect in managed code, a managed assembly is used to define the BitmapEffect and to interact with the Component Object Model (COM) library. To use this custom effect in an application, the assembly must be referenced and the effect must use the namespace referenced by the assembly. For the complete sample, see Custom BitmapEffect Sample - RGBFilter.

The following example shows how to define a namespace and reference the assembly that implements the custom effect.

<Window x:Class="RGBFilterEffectTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="RGBFilterEffectTest" Height="400" Width="300"
    xmlns:RGBFilter="clr-namespace:RGBFilter;assembly=ManagedRGBFilterBitmapEffect"
    xmlns:MappingPIGen1="clr-namespace:RGBFilter;assembly=ManagedRGBFilterBitmapEffect">

The following example uses the custom effect by referencing the namespace provided in the above example.

<Image Name="RTB" Source="images/kittens.jpg">
  <Image.BitmapEffect>
    <RGBFilter:RGBFilterBitmapEffect >
      <RGBFilter:RGBFilterBitmapEffect.Red>
        <Binding ElementName="redSlider" Path="Value"/>
      </RGBFilter:RGBFilterBitmapEffect.Red>
      <RGBFilter:RGBFilterBitmapEffect.Green>
        <Binding ElementName="greenSlider" Path="Value"/>
      </RGBFilter:RGBFilterBitmapEffect.Green>
      <RGBFilter:RGBFilterBitmapEffect.Blue>
        <Binding ElementName="blueSlider" Path="Value"/>
      </RGBFilter:RGBFilterBitmapEffect.Blue>
    </RGBFilter:RGBFilterBitmapEffect >
  </Image.BitmapEffect>
</Image>

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Freezable
         System.Windows.Media.Animation.Animatable
          System.Windows.Media.Effects.BitmapEffect
             Derived Classes

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft