Home › Forums › TWAIN Classic › mutiple page scanning
- This topic has 1 reply, 2 voices, and was last updated 16 years, 2 months ago by gabe.
- AuthorPosts
Hi,
I’m running the below pasted code when source is ready for transfer.
Scanner is Canon 2050C, it’s a documet scanner.public ArrayList TransferPictures()
{
ArrayList pictures = new ArrayList();
if (_sourceIdentity.Id == IntPtr.Zero)
return pictures;
TwRC returnCode;
IntPtr hbitmap = IntPtr.Zero;
TwPendingXfers pendingTransfer = new TwPendingXfers();do
{
pendingTransfer.Count = 0;
hbitmap = IntPtr.Zero;
TwImageInfo imgInfo = new TwImageInfo();
returnCode = DSiinf(_appid, _sourceIdentity, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, imgInfo);
if (returnCode != TwRC.Success)
{
CloseSource();
return pictures;
}returnCode = DSixfer(_appid, _sourceIdentity, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
}
if (returnCode == TwRC.Failure)
MessageBox.Show(“Failure #7”);if (returnCode != TwRC.XferDone)
{
CloseSource();
return pictures;
}returnCode = DSpxfer(_appid, _sourceIdentity, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pendingTransfer);
if (returnCode == TwRC.Failure)
MessageBox.Show(“Failure “);if (returnCode != TwRC.Success)
{
CloseSource();
return pictures;
}pictures.Add(hbitmap);
}
while (pendingTransfer.Count != 0);returnCode = DSpxfer(_appid, _sourceIdentity, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pendingTransfer);
if (returnCode == TwRC.Failure)
MessageBox.Show(“Failure #9”);
return pictures;
}FYI, I’ve set source capability to TwCapability srcCapability = new TwCapability(TwCap.XferCount, -1); before acquire.
The scenario is I’m scanning mutiple page one by one.
Now my problem is pendingTransfer.Count always remains 1 until DSixfer returns a value equal to ‘cancel’.
In otherwords, let’s say I’m scanning 3 pages one by one but the do-while executes four time. So is there any way find out that no paper is left in the tray. FYI, I checked on internet for CAP_PAPERDETECTABLE but this capability is not supported by my scanner.Can anyone in this group help me.
Thanks,
Mcould very well be the case that the scanner doesn’t ‘know’ how many pages are next or that at only knows if there is or is not one more page remaining.
You should count on scanners not knowing how many pages remain and code to handle either the count == 0 case or the ImageNativeXfer Get returning failure case to indicate that scanning is complete.
One question, how does you code handle a paperjam?
- AuthorPosts