The process of negotiating ICAP_FRAMES is the same as all the other capabilities. However, Frame has 4 data members: Left, Top, Right and Bottom, which can not be held in CapValue or CapValueString properties. Dynamic TWAIN provides several methods to deal with Frame: CapGetFrameLeft(), CapGetFrameTop(), CapGetFrameRight(), CapGetFrameBottom() and CapSetFrame().
For the general steps of capability negotiation, please refer to How to Negotiate Capability with Different Capability Container Types.
The followings are the samples of ICAP_FRAMES negotiation:
C# Sample:
int lngIndex = 0;
string strFrame;
Twain.OpenSource();
Twain.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_FRAMES;
if (!Twain.CapGet())
{
MessageBox.Show("Failed.\r\n" + Twain.ErrorString);
return;
}
if (Twain.CapType == Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE)
{
strFrame = "Frame left: " + Twain.CapGetFrameLeft(0) + "\r\n";
strFrame = strFrame + "Frame top: " + Twain.CapGetFrameTop(0) + "\r\n";
strFrame = strFrame + "Frame right: " + Twain.CapGetFrameRight(0) + "\r\n";
strFrame = strFrame + "Frame bottom: " + Twain.CapGetFrameBottom(0);
MessageBox.Show(strFrame);
}
else if (Twain.CapType == Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ENUMERATION)
{
for (lngIndex = 0; lngIndex < Twain.CapNumItems; lngIndex++)
{
strFrame = "Frame left: " + Twain.CapGetFrameLeft(lngIndex) + "\r\n";
strFrame = strFrame + "Frame top: " + Twain.CapGetFrameTop(lngIndex) + "\r\n";
strFrame = strFrame + "Frame right: " + Twain.CapGetFrameRight(lngIndex) + "\r\n";
strFrame = strFrame + "Frame bottom: " + Twain.CapGetFrameBottom(lngIndex);
MessageBox.Show(strFrame);
}
}
|
C# Sample:
Twain.OpenSource();
Twain.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_FRAMES;
Twain.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE;
Twain.CapSetFrame(0, 0, 0, 5, 5);
if (Twain.CapSet())
MessageBox.Show("Successful.");
else
MessageBox.Show("Failed.\r\n" + Twain.ErrorString);
|
C# Sample:
Twain.OpenSource();
Twain.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_FRAMES;
Twain.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ENUMERATION;
Twain.CapNumItems = 2;
Twain.CapSetFrame(0, 0, 0, 5, 5);
Twain.CapSetFrame(1, 6, 6, 8, 8);
if (Twain.CapSet())
MessageBox.Show("Successful.");
else
MessageBox.Show("Failed.\r\n" + Twain.ErrorString);
|