现在我想改变大小,通过下面的代码,发现还是120x160,不知道什么地方出错了
int iCount=0;
int iSize=0;
hResult=m_pCaptureGraphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Interleaved,m_pVideoCaptureFilter,IID_IAMStreamConfig,(void**)&pAMStreamConfig);
if(hResult==S_OK)
{
hResult=m_pCaptureGraphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,m_pVideoCaptureFilter,IID_IAMStreamConfig,(void**)&pAMStreamConfig);
hResult = pAMStreamConfig->GetNumberOfCapabilities(&iCount, &iSize);
if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
{
// Use the video capabilities structure.
for (int iFormat = 0; iFormat < iCount; iFormat++)
{
VIDEO_STREAM_CONFIG_CAPS scc;
AM_MEDIA_TYPE *pmtConfig;
hResult = pAMStreamConfig->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc);
if (SUCCEEDED(hResult))
{
/* Examine the format, and possibly use it. */
// Delete the media type when you are done.
if(pmtConfig->majortype == MEDIATYPE_Video)
{
VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;
pVih->bmiHeader.biWidth=640;
pVih->bmiHeader.biWidth=480;
pVih->bmiHeader.biSizeImage = DIBSIZE(pVih->bmiHeader);
hResult = pAMStreamConfig->SetFormat(pmtConfig);//重新设置视频格式
}