Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Multimedia API Help

IltmmCapture::get_TargetStream Example for C

Show in webframe

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); 
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.