Home › Forums › TWAIN Classic › How to dynamically determine scanned paper size › Reply To: How to dynamically determine scanned paper size
January 14, 2008 at 5:29 pm #24263
I have looked through the examples you posted and the OpenTwain project you refer to. I have been using the same logic as you are. I actually got my code from the sample project on http://www.codeproject.com/dotnet/twaindotnet.asp.
This is what I have been running. I apologize for not posting all of it to begin with.
do
{
pxfr.Count = 0;
hbitmap = IntPtr.Zero;
// Per the examples, here is where I am supposed to capture ImageInfo and ImageLayout ...
// But when this code runs the paper is still laying in the tray unscanned.
iinf = new TwImageInfo();
rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf);
if (rc != TwRC.Success)
{
CloseSrc();
return pics;
}
ilyt = new TwImageLayout();
rc = DSilayout(appid, srcds, TwDG.Image, TwDAT.ImageLayout, TwMSG.Get, ilyt);
if (rc != TwRC.Success)
{
CloseSrc();
return pics;
}
// Store the returned values into my struct - But the values are always the same
// regardless if the paper is 8.5x11 or 5x6
imf = new ImgInfo();
imf.sizeX = iinf.ImageWidth;
imf.sizeY = iinf.ImageLength;
imf.posLeft = ilyt.Frame.Left.ToFloat();
imf.posRight = ilyt.Frame.Right.ToFloat();
imf.posTop = ilyt.Frame.Top.ToFloat();
PictureInfo.Add(imf);
// Now the paper is fed throught the machine and scanned
rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
if (rc != TwRC.XferDone)
{
CloseSrc();
return pics;
}
// Right here is where I would expect to be able to get my information because the documents have now been scanned.
rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr);
if (rc != TwRC.Success)
{
CloseSrc();
return pics;
}
pics.Add(hbitmap);
}
while (pxfr.Count != 0);
Is there a setting that would cause the scanner to pull in the paper when I call rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf); and rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf); ?