HRESULT GetCaptureVideoFormatCount(IltmmCapture *pCapture){HRESULT hr;long lIndex, lCount, lSelection, lWidth, lHeight, lCompression, lBitCount;VARIANT_BOOL vSelected;BSTR SubTypeName, SubTypeFriendlyName, Subtype;IltmmVideoFormats* pVidCapFormats = NULL;IltmmVideoFormat* pVidFormat = NULL;// try to get the capture video formatshr = pCapture->get_VideoCaptureFormats(&pVidCapFormats);if (FAILED(hr))return hr;// get the count herehr = pVidCapFormats->get_Count(&lCount);if (FAILED(hr)){// release the capture formats objectpVidCapFormats->Release();return hr;}// get the selected formathr = pVidCapFormats->get_Selection(&lSelection);if (FAILED(hr)){// release the capture formats objectpVidCapFormats->Release();return hr;}// if the first format is not selected, select itif (lSelection != 0){hr = pVidCapFormats->put_Selection(0);if (FAILED(hr)){// release the capture formats objectpVidCapFormats->Release();return hr;}}// get the first format objecthr = pVidCapFormats->Item(0, &pVidFormat);if (FAILED(hr)){// release the capture formats objectpVidCapFormats->Release();return hr;}// check it's selected statehr = pVidFormat->get_Selected(&vSelected);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}// if it is not selected, select itif (vSelected == VARIANT_FALSE){hr = pVidFormat->put_Selected(VARIANT_TRUE);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}}// get the format's subtype namehr = pVidFormat->get_SubTypeName(&SubTypeName);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}// do something with the subtype name bstr and then free itSysFreeString(SubTypeName);// get the format's friendly namehr = pVidFormat->get_SubTypeFriendlyName(&SubTypeFriendlyName);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}// do something with the friendly name bstr and then free itSysFreeString(SubTypeFriendlyName);// get the format's widthhr = pVidFormat->get_Width(&lWidth);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}// get the format's heighthr = pVidFormat->get_Height(&lHeight);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}// get the format's compressionhr = pVidFormat->get_Compression(&lCompression);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}// get the format's bit counthr = pVidFormat->get_BitCount(&lBitCount);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}Subtype = SysAllocString(ltmmMEDIASUBTYPE_RGB24);// find a video format with subtype RGB24, 1024x768hr = pVidCapFormats->Find(Subtype, 1024, 768, &lIndex);SysFreeString(Subtype);if (FAILED(hr)){// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return hr;}// release the capture formats and selected format objectpVidCapFormats->Release();pVidFormat->Release();return S_OK;}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
