共用方式為


Win32 Sample Codec

This sample demonstrates how to create a custom codec can be built using the unmanaged Microsoft Windows Presentation Foundation Imaging Component API.

This sample creates both an encoder and decoder that can be registered with the WPF Imaging system so that it can be automatically used by WPF applications. In addition, this sample demonstrates how to create pixel format converters.

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 - WPF 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 2005, 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 codec library. From the command window, execute regsvr32 on the dynamic-link library (DLL) in the Debug or Release folder contained in the AITCodec source folder.

  2. Run the Sample

    • This sample has no executable and only demonstrates how to create a custom codec. Once the codec is registered and the library is signed, the codec will be automatically recognized by a WPF application.

Remarks

To use a custom codec, the codec must be registered and be digitally signed.

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".

For details on the sample codec block structure see the readme.html included with the sample.

See Also

Reference

Unmanaged WPF Imaging Component