Home › Forums › TWAIN Classic › Mulli Image Scanning
- This topic has 3 replies, 3 voices, and was last updated 15 years, 5 months ago by jimwatters.
- AuthorPosts
Hi..
I have a java scanner application.that call twain wrapper (C++).
I opendsm,opends and enableds ,then after coming the scanner window.
I pressed scan button,then just scan a one page(I have loaded 10 pages in my ADF scanner).
How to do that acquire all pages,by pressing scan button
ThnxRegrads
AmilaYou need to set cap_xfercount to -1, it will scan all the pages in the feeder.
@amila123 wrote:
Hi..
I have a java scanner application.that call twain wrapper (C++).
I opendsm,opends and enableds ,then after coming the scanner window.
I pressed scan button,then just scan a one page(I have loaded 10 pages in my ADF scanner).
How to do that acquire all pages,by pressing scan button
ThnxRegrads
AmilaI set CAP_XFERCOUNT as -1. my code is below
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 no=JNI_FALSE;
image = BMP_transferImage(env,clazz,&no,(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) && pxfers.Count != 0);It just scan one page..what can be the problem ?
Regards
AmilaI believe your last call with DG_CONTROL,DAT_PENDINGXFERS,MSG_RESET inside your do loop is to blame. Remove this.
(*DSM_ENTRY) (&g_AppID,&g_SrcID,DG_CONTROL,DAT_PENDINGXFERS,MSG_RESET,(TW_MEMREF) &pxfers);
- AuthorPosts