Home › Forums › TWAIN Classic › Image Aquire Problems
- This topic has 1 reply, 2 voices, and was last updated 14 years, 1 month ago by mmotovsk.
- AuthorPosts
Hi..
I have a java application that call C++ Twain wrapper.
I have stucked in multi Image Aquiring…
My scanner is fujitsu fi6130(ADF scanner).What I have done in acquire method is bellow.
TW_CAPABILITY twCapability;
pTW_ONEVALUE pval;twCapability.Cap = CAP_XFERCOUNT;
twCapability.ConType = TWON_ONEVALUE;
twCapability.hContainer = GlobalAlloc (GHND, sizeof (TW_ONEVALUE));
pval = (pTW_ONEVALUE) GlobalLock (twCapability.hContainer);
pval->ItemType = TWTY_INT16;
pval->Item = -1;
GlobalUnlock(twCapability.hContainer);
g_rc = (*DSM_ENTRY) (&g_AppID, &g_SrcID, DG_CONTROL, DAT_CAPABILITY, MSG_SET, ( TW_MEMREF)&twCapability);
if(g_rc == TWRC_SUCCESS)
printf(“CAP_XFERCOUNT Succ n”);
else
printf(“CAP_XFERCOUNT failed n”);/*
*/TW_USERINTERFACE ui;
ui.ShowUI = TRUE;
ui.ModalUI = TRUE;
ui.hParent = 0;g_rc = (*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_CONTROL,DAT_USERINTERFACE,MSG_ENABLEDS,&ui);
if (g_rc != TWRC_SUCCESS)
{
JNU_Throwexception(env,”scanner/TwainException”,”Unable to enableDS”);
}bool nonTWAINProblem = FALSE;
MSG msg;
TW_EVENT event;
TW_PENDINGXFERS pxfers;do
{
event.pEvent = (TW_MEMREF) &msg;
event.TWMessage = MSG_NULL;g_rc = (*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF) &event);
if (g_rc == TWRC_NOTDSEVENT)
{
TranslateMessage ((LPMSG) &msg);
DispatchMessage ((LPMSG) &msg);
continue;
}if (event.TWMessage == MSG_XFERREADY)
{
nextImage:
TW_IMAGEINFO ii;
g_rc = (*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_IMAGE,DAT_IMAGEINFO,MSG_GET,(TW_MEMREF) &ii);if (g_rc == TWRC_FAILURE)
{
(*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_CONTROL,DAT_PENDINGXFERS,MSG_RESET,(TW_MEMREF) &pxfers);
JNU_Throwexception(env,”TwainException”,”Unable to obtain image Info”);
break;
}HGLOBAL handle;
g_rc = (*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_IMAGE,DAT_IMAGENATIVEXFER,MSG_GET,(TW_MEMREF) &handle);
if (g_rc == TWRC_XFERDONE)
{
BITMAPINFOHEADER* lpbmih=(BITMAPINFOHEADER*)GlobalLock(handle);
jboolean hasException=JNI_FALSE;
image = BMP_transferImage(env,clazz,&hasException,(HGLOBAL)handle);GlobalUnlock ((HANDLE) handle);
GlobalFree ((HANDLE) handle);g_rc = (*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_CONTROL,DAT_PENDINGXFERS,MSG_ENDXFER,(TW_MEMREF) &pxfers);
}
(*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_CONTROL,DAT_PENDINGXFERS,MSG_RESET,(TW_MEMREF) &pxfers);
}
}while (GetMessage ((LPMSG) &msg, 0, 0, 0) and pxfers.Count != 0);When I press the scanner button it just scan a one page.scanner tray has loaded more pages.What can be the reason for this to stay after scan a one page ?
Please help..Regards
AmilaI do not know to help you in your code. But if you can use Morena Image Acquisition Framework for Java (http://www.gnome.sk), you can try the following code design:
TwainSource source=TwainManager.selectSource(null);
if (source!=null)
{ source.setFeederEnabled(true);
source.setAutoFeed(true);
source.setTransferCount(5);
int count=1;
do
{ MorenaImage image=new MorenaImage(source);
System.err.println("Size of acquired image "+(count++)+" is "
+image.getWidth()+" x "
+image.getHeight()+" x "
+image.getPixelSize());
}
while (source.hasMoreImages());
}
TwainManager.close();
Morena is a commercial product, but it is free of charge for educational and personal home usage.
Martin Motovsky
Member of Gnome’s technical support- AuthorPosts