Microsoft DirectX 9.0

Alpha Blending

This article describes alpha blending in Microsoft® DirectShow® Editing Services (DES).

Alpha measures the transparency of a pixel or image. In 32-bit uncompressed RGB video, four components define each pixel: an alpha channel (A) and three color components (RGB). A pixel with an alpha value of zero is completely transparent. A pixel with an alpha value of 255 is opaque. Between these values, the pixel has various degrees of transparency.

DirectShow defines two media types for 32-bit RGB video:

To perform alpha blending in DES, set the video group's uncompressed media type to MEDIASUBTYPE_ARGB32. In C++, call the IAMTimelineGroup::SetMediaType method. In the XTL format, setting the bitdepth attribute of the group element to 32 accomplishes this as well.

Next, you need video data that contains an alpha channel. There are several options:

If your video source does not have alpha, you can use an effect that creates alpha data. The Alpha Setter Effect sets the alpha channel for the entire image to a constant value. To vary the alpha over time, use the IPropertySetter interface with the Alpha Setter Effect. The original source does not have to be 32 bits, as long as the group's uncompressed media type is MEDIASUBTYPE_ARGB32.

Finally, pass the video to an effect or transition that performs alpha blending. The Compositor Transition performs alpha blending, and the Key Transition can key by alpha value.

The following sample XTL project performs alpha blending:

<group type="video" bitdepth="32" width="320" height="240">
  <clip start="0" stop="6" src="c:\Example.avi" />
  <clip start="0" stop="6" src="c:\Example2.avi">
    <!-- Alpha Setter effect. -->
    <effect clsid="{506D89AE-909A-44f7-9444-ABD575896E35}" start="0" stop="6">
      <param name="alpha" value="255">
        <linear time="6" value="0" />
  <!-- Key transition, with alpha keying. -->
  <transition clsid="{C5B19592-145E-11d3-9F04-006008039E37}" start="0" stop="6">
    <param name="KeyType" value="3" />