Custom BitmapEffect Sample - RGBFilter

This sample demonstrates how to create a custom BitmapEffect and use the effect in a Windows Presentation Foundation (WPF) application.

The sample is separated into three projects; an unmanaged Component Object Model (COM) library, a managed assembly, and a managed usage example. The unmanaged library project performs the actual effect manipulation and implements the necessary interfaces for a custom effect. The managed assembly defines the effect for use in managed code and performs the necessary interactions with the effect library. The usage example uses the assembly to demonstrate the custom effect.

This sample demonstrates a specific feature of the Windows Presentation Foundation (WPF) and, consequently, does not follow application development best practices. For comprehensive coverage of Windows Presentation Foundation (WPF) and Microsoft .NET Framework application development best practices, refer to the following as appropriate:

Accessibility - Accessibility Best Practices

Security - Windows Presentation Foundation Security

Localization - WPF Globalization and Localization Overview

Download sample

Building the Sample

  1. Install the Windows Software Development Kit (SDK) and open its build environment command window. On the Start menu, point to All Programs, Microsoft Windows SDK, and then click CMD Shell.

  2. Update the header and library paths. Follow the instructions provided in section 6.2 of the Windows SDK readme to update the development environment paths.

  3. Download the sample, usually from the software development kit (SDK) documentation, to your hard disk drive.

  4. Build the sample.

    • To build the sample in Microsoft Visual Studio, load the sample solution or project file and then press CTRL+SHIFT+B.

    • To build the complete sample from the build environment command window, navigate to the solution folder. At the command prompt, type MSBUILD.

    • To build the individual projects from the build environment command window, navigate to the each project folder. At the command prompt, type MSBUILD.

Running the Sample

  1. Register the unmanaged library. From the command window, execute regsvr32 on the dynamic-link library (DLL) in the Debug or Release folder contained in the RGBFilterEffectLib source folder.

  2. Run the Sample

    • To run the sample with Microsoft Visual Studio 2005, select the RGBFilterEffectTest and then press F5.

    • To run the sample form the build environment command window, execute the .exe in the Bin\Debug or Bin\Release folder of the RGBFilterEffectTest folder.

Remarks

When you build this sample on Windows Vista, administrative rights are needed to register the dynamic-link library (DLL). The command window may need to be run as administrator by right-clicking the command shortcut and selecting "run as administrator".

See Also

Reference

Unmanaged WPF Bitmap Effects