This function will write the contents of the target data for the passed capture object to a disk file.
void IltmmCapture_get_TargetStream_Example (const char *lpszFileName, IltmmCapture* pCapture)
{
HANDLE hFile = NULL;
long fl = 0;
unsigned long lBytesWritten;
IltmmMemory *pTarget = NULL;
VARIANT varData;
unsigned char *pBuffer = NULL;
SAFEARRAY sa;
// write the data to a file
hFile = CreateFile(lpszFileName, // open file name
GENERIC_WRITE, // open for writing
FILE_SHARE_READ, // share for reading
NULL, // no security
CREATE_ALWAYS, // re-create the file
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
if (hFile == INVALID_HANDLE_VALUE)
{
return;
}
IltmmCapture_get_TargetStream(pCapture, (IUnknown**)&pTarget);
if(!pTarget)
return;
IltmmMemory_get_BufferSize(pTarget, &fl);
VariantInit(&varData);
// pass data
memset(&sa, 0, sizeof(sa));
sa.cbElements = sizeof(unsigned char);
sa.cDims = 1;
sa.fFeatures = (FADF_AUTO | FADF_FIXEDSIZE);
sa.pvData = (UCHAR*) malloc(sizeof(UCHAR)*fl);
sa.rgsabound[0].cElements = fl;
V_VT(&varData) = (VT_ARRAY | VT_UI1);
V_ARRAY(&varData) = &sa;
IltmmMemory_CopyData(pTarget, 0, fl, &varData);
SafeArrayAccessData(V_ARRAY(&varData), (void**)&pBuffer);
WriteFile(hFile, pBuffer, fl, &lBytesWritten, NULL);
SafeArrayUnaccessData(V_ARRAY(&varData));
VariantClear(&varData);
CloseHandle(hFile);
IltmmMemory_Release(pTarget);
}
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