How Transforms Work

In a general sense, each transform is a set of rules for how to produce one graphic output. The design of a generic transform is shown in the following illustration.

Typically, a transform has one or several inputs that are used to produce the output graphics. Some transforms even have optional inputs and produce different effects based on how many inputs are defined. It is also possible for a transform to have no inputs.

Transforms can have a number of properties that determine how to process the inputs. In many cases, changing the values of these properties enables you to produce drastically different output with the same input.

This article contains the following sections.

  • Transform Properties
  • How to Use Transforms
  • Related topics

Transform Properties

Each transform has a number of properties that control how the output is produced. The effect of each property on the output is controlled by changing a value associated with the property. Some are generic properties for all transforms, which are part of the Microsoft DirectX Transform code framework. The rest are referred to as custom properties, which are specific to a particular transform.

The most commonly used generic property is IDXEffect::Progress. It is used for all transforms that make smooth transitions from one state to another. The value for IDXEffect::Progress can range from 0.0 to 1.0, determining what fraction of the transition should be reflected in the transform output. By looping over steadily changing values for IDXEffect::Progress and producing output at each step, the transition can appear to be a repeating animation.

There are a number of other generic properties that can control transform output. The CDXBnds::Duration property stores how long a transition from IDXEffect::Progress = 0.0 to IDXEffect::Progress = 1.0 should take. Some transforms support the Quality property, which determines quality or resolution of the output. Note that though these generic properties are available for all transforms, not all transforms use them.

The custom properties of a transform depend on the type of effect a transform produces. These are listed for each transform in the Transform Reference section. Examples of transforms and their custom properties are shown at the end of this article.

How to Use Transforms

You typically follow four steps to use a transform.

  1. Create the transform. Use C++ with a Component Object Model (COM) interface called an IDXTransformFactory.
  2. Define inputs and outputs. Load into memory or create input images, if the transform uses them. After creating an output object of the correct type, pass pointers to these objects to the IDXTransform::Setup method.
  3. Set the values for transform properties. This is done with two implied access methods for each property: put_Property and get_Property. For example, a custom property named MyProperty. can be set with put_MyProperty and retrieved with get_MyProperty. There are also put_Progress and get_Progress methods for transforms that support IDXEffect.
  4. Call the IDXTransform::Execute method, which processes the inputs according to the transform properties and produces the output.

After the call to IDXTransform::Execute, the output object is typically drawn to the screen. For transforms that support the IDXEffect::Progress property, you can create animated effects. This is typically done by creating a loop that, for each iteration, sets a new value for IDXEffect::Progress and calls IDXTransform::Execute.

These steps are covered in more detail in the Using Transforms in C++ article.

Visual Filters and Transitions Reference