Microsoft DirectX 9.0 |
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:
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);
}
}