This tutorial shows the most efficient way of creating a BITMAPHANDLE from a frame sample.
The following is an overview of the process:
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.
You should create a ltmmMediaType object and set its:
Type to be video (using IltmmMediaTypeDisp::put_type)
Subtype to uncompressed RGB24 or 8-bit (using IltmmMediaTypeDisp::put_subtype) because this is the only type of data LEADTOOLS can use
Call IltmmSampleTarget::SetAcceptedMediaType to set the output sample type. You can also free the ltmmMediaType object since it is not needed anymore.
Specify that the output from ltmmConvert object will be the target sample grabber by calling IltmmConvert::put_TargetObject.
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.
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.
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 each sample:
Note
The shell bitmap should not be used after calling IltmmSampleTarget::Release. You should only call L_FreeBitmap or L_SetBitmapDataPointer beyond this point.
Stop the conversion by calling IltmmConvert::StopConvert and free any memory (other than the bitmap data) allocated for the shell bitmap using L_FreeBitmap.
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 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