Use Frames from the Multimedia Toolkit with the Rest of LEADTOOLS Without Video Filter Callback

This tutorial shows the most efficient way of creating a BITMAPHANDLE  from a frame sample. (For information on the BITMAPHANDLE structure, refer to the Ltdlln.chm help file in the HELP folder.)

The following is an overview of the process:

1. ltmmConvert and ltmmCapture objects can pass you each sample using the IltmmMediaSampleDisp Interface. For simplicity, we will be using the ltmmConvert object from now on, but similar steps would be used with the ltmmCapture object.
2. You should create a ltmmMediaType object and set its:
  a. Type to be video (using IltmmMediaTypeDisp::put_type)
  b. Subtype to uncompressed RGB24 or 8-bit (using IltmmMediaTypeDisp::put_subtype) because this is the only type of data LEADTOOLS can use
3. Call IltmmSampleTarget::SetAcceptedMediaTypeto set the output sample type. You can also free the ltmmMediaType object since it is not needed anymore.
4. Specify that the output from ltmmConvert object will be the target sample grabber by calling IltmmConvert::put_TargetObject.
5. Make the convert object create its graph to know the size of the output samples. You can call IltmmConvert::put_SourceFile to tell it to start converting from an AVI file. Call IltmmConvert::StartConvert to force the filter to build the filter graph and update the output type.
6. Get the ltmmMediaType object which will be used by the sample grabber object by calling IltmmSampleTarget::GetConnectedMediaType. Get the dimensions of the samples by calling IltmmMediaTypeDisp::get_Format.
7. Use the width and height from the media type and create the shell LEADTOOLS bitmap by calling L_CreateBitmap  and passing TYPE_USER for uMemory parameter. You can pass NULL for data if you do not have the data yet. (For information on the L_CreateBitmap function, refer to the Ltdlln.chm help file in the HELP folder.)
8. For each sample:
  a. Retrieve a sample using IltmmSampleTarget::GetSample.
  b. Call IltmmMediaSampleDisp::get_Buffer to get direct access to the sample data
  c. Call L_SetBitmapDataPointer  to set the LEADTOOLS bitmap data pointer to the sample data. (For information on the L_SetBitmapDataPointer function, refer to the Ltdlln.chm help file in the HELP folder.)
  d. Use the LEAD bitmap.
  e. Release the sample by calling IltmmSampleTarget::Release.
    Note: The shell bitmap should not be used after calling IltmmSampleTarget::Release. You should only call L_FreeBitmap  or L_SetBitmapDataPointer  beyond this point! (For information on the L_FreeBitmap function or the L_SetBitmapDataPointer function, refer to the Ltdlln.chm help file in the HELP folder.)
9. Stop the conversion by calling IltmmConvert::StopConvert and free any memory (other than the bitmap data) allocated for the shell bitmap using L_FreeBitmap.

Example

For a C example, refer to Splitting an AVI File into a Multipage TIFF File Using ltmmSampleTarget for C.

For a C++ example, refer to Splitting an AVI File into a Multipage TIFF File Using ltmmSampleTarget for C++.

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Multimedia C API Help