ICImagingControl.MemoryGetDib Method

This method is used to pass a Device Independent Bitmap to other programming tools for further processing.
Syntax:
Public Function MemoryGetDib() As Long
Return Value:

A handle to a Device Independent Bitmap (DIB).

Remarks:

If the LiveStart method has not been called, MemorySnapImage builds a filtergraph on its own whenever MemorySnapImage is called. If MemorySnapImage is called more than once, it is suggested to call LiveStart before calling MemorySnapImage.

This frees MemorySnapImage from initialization tasks it would otherwise have to perform each time it is called.

MemoryGetDib allocates global memory every time it is called. This memory is not released, because this would release the DIB in the other programming tools. So calling MemoryGetDib too often would cause an out of memory error. To prevent running out of memory an application needs to free this memory.

A global variable PicMemPointer needs to be added to the form:

Dim PicMemPointer As Long

The Windows function GlobalFree() frees global memory. It is implemented in kernel32.lib. The GlobalFree() function needs to be declared as follows in the form:

Private Declare Function GlobalFree Lib "kernel32" _
                         (ByVal hMem As Long) As Long

The example must be extended to:

Private Sub cmdLead_Click()
    ICImagingControl1.MemorySnapImage
    GlobalFree PicMemPointer
    PicMemPointer = ICImagingControl1.MemoryGetDib
    Form1.LEAD1.SetDIB PicMemPointer
End Sub
Sample:

This example snaps an image and passes it to a Leadtools control:

Private Sub cmdLead_Click()
    ICImagingControl1.MemorySnapImage
    Form1.LEAD1.SetDIB ICImagingControl1.MemoryGetDib
End Sub

Note that Leadtools is not a product of The Imaging Source and is not shipped with IC Imaging Control.

See also: ICImagingControl, ICImagingControl.MemoryGetImageData

<< ICImagingControl