Home › Forums › TWAIN Classic › Setting XferCount to -1
- This topic has 1 reply, 2 voices, and was last updated 13 years, 4 months ago by peterp.
- AuthorPosts
Hi guys,
in my application I am stucked on one problem and that is setting the count of images to be transfered to -1 (I have pasted my code below)
The function is a real mystery to me. Everything looks fine. Every DSM call returns TWRC_SUCCESS, even when I check the current value of the capability it returns 65536 => -1.
The only problem is that my camera want to close DS after every transfer.
From DS i recieve MSG_XFERREADY, so I transfer image. BUT when I query the count of images to be transfered next, it ALWAYS returns 0 and next message I recieve from DSM is MSG_CLOSEDSREQ, so I have to close it.I am quite desperate because I need to grab images one after another to simulate “video stream”.
I hope I have described my problem clear enough, if no please ask.
bool TWSetXferCount(unsigned short count) {
bool result = false;
TW_UINT32 twRC;
TW_CAPABILITY twCap;
pTW_ONEVALUE pval;
twCap.Cap = CAP_XFERCOUNT;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = GlobalAlloc(GHND, sizeof(TW_ONEVALUE));
pval = (pTW_ONEVALUE) GlobalLock(twCap.hContainer);
pval->ItemType = TWTY_INT16;
pval->Item = count;
GlobalUnlock(twCap.hContainer);
if((twRC=CallDSMEntry(&appID,
&dsID,
DG_CONTROL,
DAT_CAPABILITY,
MSG_SET,
(TW_MEMREF)&twCap)) != TWRC_SUCCESS) {
StatusText("Couldn't set the count of images");
}
GlobalFree((HANDLE)twCap.hContainer);
// next I check the current value of the capability
twCap.Cap = CAP_XFERCOUNT;
twCap.ConType = TWON_DONTCARE16;
twCap.hContainer = NULL;
twRC = CallDSMEntry(&appID,
&dsID,
DG_CONTROL,
DAT_CAPABILITY,
MSG_GET,
(TW_MEMREF)&twCap);
pval = (pTW_ONEVALUE) GlobalLock(twCap.hContainer);
if (count == pval->Item)
result = true;
else
result = false;
GlobalUnlock(twCap.hContainer);
return result;
}Thanks
You appear to be doing everything correctly. There is no requirement that a data source has to allow you to transfer multiple images.
If your data source is telling you there are no more images after you retreive one, then you need to disable or close the data source and then reopen or reenable it to get the next image. This is a design choice by the camera vendor.
There may also be some custom capability to do continous scanning, but your camera vendor would be the only one who can tell you that.
- AuthorPosts