The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Java Tech: Acquire Images with TWAIN and SANE, Part 2
Subject:  Setting other ICAP properties in scanner...
Date:  2005-05-26 09:17:30
From:  javajeff
Response to: Setting other ICAP properties in scanner...


The following line from your latest source code is problematic:

pTW_FRAME pFrame = (pTW_FRAME)GlobalAlloc(GHND,(sizeof(TW_FRAME)));

GlobalAlloc() returns a handle. You must call GlobalLock() to lock the memory identified by the handle before you can assign its address to pFrame. The correct code appears below:

HANDLE handle = GlobalAlloc (GHND, sizeof(TW_FRAME));
if (handle == 0)
{
throwJTE (env, "Insufficient Memory (setFrames");
return;
}

pTW_FRAME pFrame = (pTW_FRAME) GlobalLock (handle);

pFrame->Left = FloatToFix32 (left);
pFrame->Top = FloatToFix32 (top);
pFrame->Right = FloatToFix32 (right);
pFrame->Bottom = FloatToFix32 (bottom);

GlobalUnlock (handle);

Even after making the change, my implementation of setFrames() is still throwing an exception. It could be that none of my data sources support ICAP_FRAMES. However, it might be something else.

I recommend making the change above and trying again. Let me know what happens.

In the meantime, I will study the code and see if I can spot any other reason for the problem.

Jeff

 Feed java.net RSS Feeds