Home › Forums › TWAIN Classic › Flatbed scanning region
- This topic has 6 replies, 3 voices, and was last updated 7 months, 1 week ago by subhajit.
- AuthorPosts
hi all,
Please help me out. My scanner is a flatbed canon scanner (canon 5600f) with twain compatible and my application is based on C#.net 3.5.
I just want to tell the scanner to scan a specific region, that means, that light bar(sensor) will travel a specific region. I found some solution in the net, but unfortunately those are not working. The sensor travel allover the region. Below is my code,
TwainImageLayout layout = new TwainImageLayout();
rc = DSilayout(appid, srcds, TwDG.Image, TwDAT.ImageLayout, TwMSG.Get, layout);
if (rc != TwRC.Success)
{
CloseSrc();
return false;
}// 1 inch from the top and 0 from the left
layout.Frame.Top.FromFloat(0);layout.Frame.Left.FromFloat(0);
layout.Frame.Right.FromFloat(6);
layout.Frame.Bottom.FromFloat(3);
layout.FrameNumber = 1;
layout.PageNumber = 1;
layout.DocumentNumber = 1;rc = DSilayout(appid, srcds, TwDG.Image, TwDAT.ImageLayout, TwMSG.Set,layout);
if (rc != TwRC.Success)
{
CloseSrc();
return false;
}Is it a right way to do that? what are the values, I should provide for Top, Left, Right, Bottom (These values are really confused me!!!!).
Please help me out.
Thanks,
subhajitknock knock, anybody plzz help me, I am just stuck………..
With your settings below, you should get 3 inch from the top and 6 inch from the left.
layout.Frame.Top.FromFloat(0);
layout.Frame.Left.FromFloat(0);
layout.Frame.Right.FromFloat(6);
layout.Frame.Bottom.FromFloat(3);You may check out a working demo using Dynamic .NET TWAIN.
When I set (0,0,8,8), we will get the image like this:
[attachment=0:1k7cjwrl]SetImageLayout – Dynamic .net twain.png[/attachment:1k7cjwrl]Related code:
private void btnSetAndAcquire_Click(object sender, System.EventArgs e)
{
float fFrameLeft, fFrameTop, fFrameRight, fFrameBottom;
try
{
fFrameLeft = Convert.ToSingle(edtFrameLeft.Text);
fFrameTop = Convert.ToSingle(edtFrameTop.Text);
fFrameRight = Convert.ToSingle(edtFrameRight.Text);
fFrameBottom = Convert.ToSingle(edtFrameBottom.Text);
}
catch (Exception)
{
MessageBox.Show("Please input numerical values in the input boxes.", "Error");
return;
}
dynamicDotNetTwain.SelectSource();
dynamicDotNetTwain.OpenSource(); //make dynamicDotNetTwain ready for capability negotiation
if (dynamicDotNetTwain.SetImageLayout(fFrameLeft,fFrameTop,fFrameRight,fFrameBottom) == false)
MessageBox.Show(dynamicDotNetTwain.ErrorString, "Error");
dynamicDotNetTwain.IfShowUI = false;
dynamicDotNetTwain.IfDisableSourceAfterAcquire = true;
dynamicDotNetTwain.EnableSource();
}Hope it helps.
Thank you very much for your reply, but can it be possible with simply using TWAIN32.dll? Because the library u have mentioned, is pretty expensive!
Please help.
Yes. Try update your code below as follows and see how it works.
layout.FrameNumber = -1;
layout.PageNumber = -1;
layout.DocumentNumber = -1;Catherine Sea
http://www.dynamsoft.comHi subhajit – is the TWAIN device in the Open state when you start that code?
and after that code, you start a scan by doing something like Enable or EnableSource?
(I don’t know this particular library you are using).Both your DSilayout calls return TWRC_SUCCESS?
Are you setting any other scanning parameters?
I hope if you are setting ICAP_UNITS at all, it is to TWUN_INCHES 😉You could download and try something like my Twirl app, to see how your Canon responds to ImageLayout.
http://eztwain.com/twirl.htm
At least then you could have the confidence that the commands *should* work, and you can concentrate on digging into the code to see where things go awry.DamomsThank you very much for your reply, but can it be possible with simply using TWAIN32.dll?
บาคาร่า
- AuthorPosts