Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, March 17, 2008 2:40:47 AM(UTC)

FrancoM  
FrancoM

Groups: Registered
Posts: 7


Hello.
I am a Delphi developer.
I am testing demo version af Lead Tools.
I have studied demo project OcrUtilityDemo and then I have created a little project to automate scanning more pages and proccess them using LTWAINBITMAPCALLBACK.
There is a problem when the call back function is called because the pUserData parameter remains null.
I tried to put my code in the demo project OCRUtilityDemo and there it run correctly; I have done many test, but without understanding what is the cause of the different running.
My code is:

interface
type
TMainFrm = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
_hBitmap: BITMAPHANDLE;
_bTwnExist: Boolean;
_hZonePen: HPEN;
_hSelZonePen: HPEN;
Procedure InitTwain();
Function InitOcrEngine(): Boolean;
public
end;

function MyTwainCallBack(hSession: HTWAINSESSION; pBitmap: pBITMAPHANDLE; pUserData: L_PVOID): L_INT;

implementation

procedure TMainFrm.FormCreate(Sender: TObject);
var
nRet: L_INT;
rAppData: APPLICATIONDATA;
begin
UNLOCKSUPPORT;
hDocument := 0;
_bTwnExist:= L_IsTwainAvailable(Handle);
if(_bTwnExist)then begin
InitTwain();
end;
InitOcrEngine();
L_InitBitmap(@_hBitmap, sizeof(BITMAPHANDLE), 0, 0, 0);
end;

procedure TMainFrm.FormDestroy(Sender: TObject);
begin
L_DocShutDown(@hDocument);
if (IsAllocated(@_hBitmap)) then L_FreeBitmap(@_hBitmap);
end;

procedure TMainFrm.Button1Click(Sender: TObject);
begin
L_TwainAcquire(hTwnSession,
nil,
sizeof(BITMAPHANDLE),
@MyTwainCallBack,
LTWAIN_SHOW_USER_INTERFACE + LTWAIN_MODAL_USER_INTERFACE,
Nil,
Self);
end;

function MyTwainCallBack(hSession: HTWAINSESSION; pBitmap: pBITMAPHANDLE; pUserData: L_PVOID): L_INT;
var
mForm: TMainFrm;
begin
mForm:= TMainFrm(pUserData);
if(IsAllocated(@mForm._hBitmap))then begin
L_FreeBitmap(@mForm._hBitmap);
L_InitBitmap(@mForm._hBitmap, sizeof(BITMAPHANDLE), 0, 0, 0);
end;
L_CopyBitmap(@mForm._hBitmap, pBitmap, sizeof(BITMAPHANDLE));
// rest of my code ...
end;
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, March 17, 2008 7:24:37 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)


What LEADTOOLS version are you using?


What does the InitTwain() function do exactly?


Can
you please try to isolate the problem in a very small sample project (not your full application) and post it here or send it to support@leadtools.com.


If
you are going to post it here please make sure that you don't hit Preview when attaching.

 
#3 Posted : Monday, March 17, 2008 9:22:16 AM(UTC)

FrancoM  
FrancoM

Groups: Registered
Posts: 7


Dear Adam Boulad
I have sent my code to support@leadtools.com.
The code is an extract of the OCRUtilityDemo included in demo of Lead Tools, with some my implementation.
The problem occurs in execution of MyTwainCallBack: hSession, pBitmap and pUserData are null.
Many thanks for your help.
Franco
 
#4 Posted : Tuesday, March 18, 2008 4:23:18 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

I have received your email and I downloaded the attachment. I will continue to work with you through emails.
I will post here the results when we reach final results.
 
#5 Posted : Saturday, March 22, 2008 9:52:48 PM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

After tracing the customer's project, I found that the Callback calling convention is not complete.
Modify the project as follows:
function MyTwainCallBack(hSession: HTWAINSESSION; pBitmap: pBITMAPHANDLE;
pUserData: L_PVOID): L_INT;

will become:

function MyTwainCallBack(hSession: HTWAINSESSION; pBitmap: pBITMAPHANDLE;
pUserData: L_PVOID): L_INT; stdcall;

That seemed to solve the issue.
 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.081 seconds.