Use ltmmCapture to Perform Simple Still Image Capture

  1. To begin simple still image capturing, create an instance of the ltmmCapture class. This is accomplished using the Win32 CoCreateInstance function as follows:

C Source

IltmmCapture* pCapture;   
CoCreateInstance(&CLSID_ltmmCapture, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmCapture, (void**) &pCapture); 

C++ Source

IltmmCapture* pCapture;    
CoCreateInstance(CLSID_ltmmCapture, NULL, CLSCTX_INPROC_SERVER, IID_IltmmCapture, (void**) &pCapture); 

  1. Define the video devices to be used as the capture source. The ltmmCapture object contains video device collection objects. The first video device can be selected for capture by calling the device collection's put_Selection function:

C Source

IltmmDevices* pDevices;   
// get an interface into video devices collection   
IltmmCapture_get_VideoDevices(pCapture, &pDevices);    
// select the first video device   
IltmmDevices_put_Selection (pDevices, 0);   
// release collection   
IUnknown_Release(pDevices); 

C++ Source

IltmmDevices* pDevices;    
// get an interface into video devices collection   
pCapture->get_VideoDevices(&pDevices);   
// select device   
pDevices->put_Selection(0);   
// release collection   
pDevices->Release(); 

  1. Define the target or output file, as demonstrated with the following code:

C Source

BSTR bstr;    
// create a string containing the target file path   
bstr = SysAllocString(L"c:\\target.mpg");    
// assign the target file path to the capture object   
IltmmCapture_put_TargetFile (pCapture, bstr);    
// free the string   
SysFreeString(bstr); 

C++ Source

BSTR bstr;    
// create a string containing the target file path   
bstr = SysAllocString(L"c:\\target.mpg");    
// assign the target file path to the capture object   
pCapture->put_TargetFile (bstr);    
// free the string   
SysFreeString(bstr); 

  1. Start capturing still image data. This is accomplished with the following code:

C Source

IltmmCapture_StartCapture (pCapture, ltmmCapture_Mode_Still); 

C++ Source

pCapture->StartCapture (ltmmCapture_Mode_Still); 

Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help