Microsoft DirectX 9.0

Configure the Video Quality

Windows Driver Model (WDM) video capture devices can support various properties that control the quality of the output, such as brightness, contrast, saturation, and so forth. To set these properties, do the following:

  1. Query the capture filter for the IAMVideoProcAmp interface.
  2. For each property that you want to control, call the IAMVideoProcAmp::GetRange method. This method returns the range of values that the device supports for that property, the default value, and the minimum increments for the settings. The IAMVideoProcAmp::Get method returns the current value of the property. The VideoProcAmpProperty enumeration defines flags for each of the properties.
  3. To set a property, call the IAMVideoProcAmp::Set method. To restore a property to its default value, use GetRange to find the default and pass that value to the Set method. You do not have to stop the filter graph when you set the properties.

The following code configures a trackbar control so that it can be used to set the brightness. The range of the trackbar corresponds to the brightness range that the device supports, and position of the trackbar corresponds to the device's initial brightness setting.

HWND hTrackbar; // Handle to the trackbar control. 
// Initialize hTrackbar (not shown).

// Query the capture filter for the IAMVideoProcAmp interface.
IAMVideoProcAmp *pProcAmp = 0;
hr = pCap->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp);
if (FAILED(hr))
{
    // The device does not support IAMVideoProcAmp, so disable the control.
    EnableWindow(hTrackbar, FALSE);
}
else
{
    long Min, Max, Step, Default, Flags, Val;

    // Get the range and default value. 
    hr = m_pProcAmp->GetRange(VideoProcAmp_Brightness, &Min, &Max, &Step,
        &Default, &Flags);
    if (SUCCEEDED(hr))
    {
        // Get the current value.
        hr = m_pProcAmp->Get(VideoProcAmp_Brightness, &Val, &Flags);
    }
    if (SUCCEEDED(hr))
    {
        // Set the trackbar range and position.
        SendMessage(hTrackbar, TBM_SETRANGE, TRUE, MAKELONG(Min, Max));
        SendMessage(hTrackbar, TBM_SETPOS, TRUE, Val);
        EnableWindow(hTrackbar, TRUE);
    }
    else
    {
        // This property is not supported, so disable the control.
        EnableWindow(hTrackbar, FALSE);
    }
}