Microsoft® DirectX® Transform objects apply space and time effects to Microsoft DirectDraw® and Direct3D® objects. DirectX Transform objects read data from a source, modify it, and write it to a destination object. In certain cases the source and destination data objects can be the same if the transform is capable of executing in place. DirectX Transform exposes a number of Component Object Model (COM) interfaces and data types that enable you to create your own unique effects and plug them into the existing architecture.
The most common use of a transform interface is to apply an effect to a DXSurface object that contains a bitmap image. Transforms can include transitions, convolutions, warps, spatial transforms, and color lookup table operations, such as brightening, contrasting, and gamma correcting. Transforms are created and initialized by using the IDXTransformFactory::CreateTransform method and are executed with the IDXTransform::Execute method.
DXSurface objects are the core image data objects for transforms. DXSurfaces wrap DirectDrawSurfaces through aggregation and provide additional functionality, such as color lookup and seamless conversion among different pixel formats. DXSurfaces can also be procedural surfaces that dynamically calculate the necessary pixel values when the surface is accessed instead of simply being an array of discrete values like a DirectDrawSurface object. Any surface that is not a DXSurface, such as a DirectDrawSurface, that is passed to a transform is wrapped into a DXSurface when the Setup method is called. This provides a standard object for all transforms to interface with and a consistent model for reading and writing pixels.
All transforms on DXSurfaces must support data access through either the IDXARGBReadPtr or IDXARGBReadWritePtr interface, or both. These interfaces provide simplified access to the underlying samples in both of the following two pixel formats: ARGB32 or alpha-premultiplied PMARGB32. Transforms gain access to these interfaces through the IDXSurface::LockSurface method and use them to call the IDXARGBReadPtr::UnPack or IDXARGBReadWritePtr::PackAndMove methods, which read and write the surface's pixels. Conversion to a common pixel format from an input surface and into an output surface simplifies the transform by making it pixel-format independent; therefore, the transform is spared the details of converting between the numerous pixel formats that are commonly used. It also allows the format of the source and the destination to differ without writing special-case transform code. If a transform recognizes both the input and output native data formats, it can go directly to the data, avoiding any intermediate conversion of the pixels. However, the pixel abstraction APIs provided are highly efficient, so writing special-case native pixel routines should be unnecessary.
Transforms describe regions of an image or mesh with the DXBNDS union structure. This structure describes an (x, y, z, t) volume in 64-bit, 32-bit, continuous, and discrete values, depending on the specific structure type. The CDXBnds template helper class can take bounds of any type and appropriately convert where necessary. Transforms should always work using bounds in their native coordinate type.
The following diagram details the process of using the IDXTransform::Execute method. This diagram assumes the transform has been created and set up correctly prior to the execution of the transform. For details on initialization and set up, see the Using Transforms in C++ section.
The previous diagram illustrates the following steps that occur when the IDXTransform::Execute method is used.
The previous diagram focuses on transforms for DXSurfaces. However, you can also create DirectX Transform objects to apply unique effects to Direct3D objects. In this case, the transform operates directly on the meshes of Direct3DRMMeshBuilder3 objects.
Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.