Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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)
[UIPermissionAttribute(SecurityAction.InheritanceDemand, Window = UIPermissionWindow.AllWindows)]
public abstract class BitmapEffect : 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>
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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.