This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Saturday, April 7, 2012 2:42:28 AM(UTC)
Groups: Registered
Posts: 101
Hi,
I am using LEAD Tools 14.5 with VB6.
At beginning, I want to clear that this is not an issue or bug or problem.
This is my query regarding the pointer of image being passed by LeadTools.
My application acquires an image from twain device in Native mode.
I am using LEADRasterTwain, LEADTwainCapability COM objects for acquisition.
I am using following line to trigger an acquisition: -
lRasterTwain.Acquire L_LTWAIN_USE_THREAD_MODE
When acquisition is over, lRasterTwain object fires an event as follows: -
Private Sub lRasterTwain_AcquirePageEvent(ByVal pBitmap As Long)
When I pass this "pBitmap" pointer further to LeadRasterIO COM control to save the image to hard disk, it saves it fine.
But in my application, I want to pass this pointer to third party (NOT Lead tools) component for further processing. The third party component is developed in C language which do not accept this pointer.
My query is that, what is "pBitmap" pointer ?
Is there any way to convert this pointer to C pointer ?
Your twain help file says it is "Pointer to the bitmap acquired from the twain source". But it do not help me much. I do not know C language, so I am not sure how should I convert this pointer to C compatible pointer.
Something about C library I wish to work with: -
This library expect pointer to RAW image array. If I read RAW image in array using following code : -
hFile = FreeFile
Open inputRawFilePath For Binary Access Read As #hFile
lFileLength = LOF(hFile)
ReDim inBuffer(lFileLength - 1)
Get #hFile, , inBuffer()
Close #hFile
And I pass inBuffer(0), to the C library, it works fine.
But, if I pass pBitmap to C library, it do not work.
I want to avoid writing the file to hard disk and again reading it in array for performance improvement.
#2
Posted
:
Sunday, April 8, 2012 6:13:21 AM(UTC)
Groups: Registered, Tech Support
Posts: 179
Amit,
What's passed to our Twain page event handler is a pointer to LEAD ActiveX bitmap object. This means the memory that the pointer references contains a complete class or object, with many properties and data values, not just raw image pixel data.
If you want a memory buffer with pixel data, you can do it as follows:
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Private Sub lRasterTwain_AcquirePageEvent(ByVal pBitmap As Long)
Dim RasterTemp as new LEADRaster
RasterTemp.Bitmap = pBitmap
Dim hMem as OLE_HANDLE
Dim iSize as Long
RasterIO.SaveMemory(RasterTemp, hMem, FILE_RAW, 24, 0, iSize)
Dim ptr
ptr = GlobalLock(hMem)
'**** use ptr because it will now contain pixel data
GlobalUnlock(hMem)
GlobalFree(hMem)
End Sub
Mohamed Abedallah
Developer Support Engineer
LEAD Technologies, Inc.

#3
Posted
:
Sunday, May 6, 2012 11:42:39 PM(UTC)
Groups: Registered
Posts: 101
Thanks, this worked perfectly.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.