Home › Forums › TWAIN Classic › Please tell me how Duplex scanning with C# program?
- This topic has 18 replies, 4 voices, and was last updated 15 years, 6 months ago by gabe.
- AuthorPosts
Dear All,
I am writting a program using twain_32.dll to scan a image. At the present the program works well with single scan mode, but not ok in duplex scan mode.
I don’t know how to set CAP_DUPLEX and CAP_DUPLEXENABLED property in my program to works well.
Could you give me sample code to do it.
In addition my program does not allow to show scan dialog when scanning.Kindness regards!
mmm, ….
you don’t set CAP_DULPEX (chapter 9, 9-371 – set not allowed), it indicates whether the scanner supports duplex; you set CAP_DUPLEXENABLED.Maybe if you post more details of what you’re doing, and where you think its going wrong i/we can offer more help.
What do you mean by ‘not ok’?
What does CAP_DUPLEX return?
Are you gettnig an RC =FAILURE or a CC = CAPUNSUPPORTED from CAP_DUPLEXENABLED?
gabe
Thanks Gabe!
Here is my source:when intDuplex param set = 1 -> Program set duplex scan mode.
public void Acquire(int intDuplex)
{
TwRC rc;
CloseSrc();
if (appid.Id == IntPtr.Zero)
{
Init(hwnd);
if (appid.Id == IntPtr.Zero)
return;
}
rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds);
if (rc != TwRC.Success)
return;TwCapability cap;
if (intDuplex == 1)
{
System.Console.WriteLine(“Duplex”);
cap = new TwCapability(TwCap.XferCount, -1);rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}cap = new TwCapability(TwCap.DuplexEnabled, 1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}cap = new TwCapability(TwCap.FeederEnabled, 1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
}
else
{
System.Console.WriteLine(“Non Duplex”);
cap = new TwCapability(TwCap.DuplexEnabled, 0);rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}cap = new TwCapability(TwCap.FeederEnabled, 0);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}cap = new TwCapability(TwCap.XferCount, 1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
}TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 0; // False
guif.ModalUI = 1; // True
guif.ParentHand = hwnd;
rc = DSuserif(appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
}Right. You may want to check the return and condition codes further on your calls. You also may want to consider checking querysupport before setting the cap.
But more directly, it looks like you abort the scan if Any of the caps you are setting return anything but success. When you step thru this with your device, where does it exit?
Could be that for your device it returns when setting xfercount (not likely but possible), duplexEnabled (more likely – specially since you don’t seem to be checking whether or how duplex is supported first, I suspect this call the most), or even feederEnabled.I’m assuming that you are certain that the device supports duplex?
So step thru it, where does it return when intDuplex==1?, and what was the specific rc and cc?
And what are you using for a source?I’m going to guess this is based on netmasters code from codeproject, did you adjust the constructor for a new cap or are you using his code as-is?
gabe
Thanks Gabe, It is difficult because I don’t have duplex scan device right now to test the program. But I will try to do it again.
Thanks again!All of the Kodak drivers have a simulation mode that allows you to test their devices. Download the drivers for the Kodak i100, i200 or i600 (or whatever device you’re interested in).
then go into %windir%twain_32kodak
you’ll see a ‘a shortcut to const.ini’ and a ‘a shortcut to ramscan.txt’From the ramscan.txt, you can see what sim modes that device supports, and you just modify the const.ini to reflect the sim you want,
so if I want to simulate a duplex device, I could download and install the i100 driver, and in const.ini set Simulate=i160 (the i160 has duplex support the i150 doesn’t)
I’ve got the i100, i200 & i600 installed along with the video DataSource from http://www.dosadi.com/beta_products.htm and of course the sample Source that came with the twain toolkit, and I rarely have to connect to a ‘live’ device to do debugging or testing.
If you come across more device simulators, post them.
gabe
Thank Gabe very much!
I will try it.Gabe!
By the way, could you tell me wether or not EPSON perfection 1670 scaner driver support simulate duplex scanning. I have searched but couln’t find resoure about it.
regards!
Unfortunately the only drivers that I know of that offer simulation are the ones I listed. Call Epson, and check the CDs that came with your Epson – I found out about the Kodak simulation mode from one of the docs from the CD – either way post back if they do or don’t offer a simulator – it’d be nice to be able to test code on more devices.
gabe
Gabe said: “All of the Kodak drivers have a simulation mode that allows you to test their devices. Download the drivers for the Kodak i100, i200 or i600 (or whatever device you’re interested in). then go into %windir%twain_32kodak
you’ll see a ‘a shortcut to const.ini’ and a ‘a shortcut to ramscan.txt’ “ I have found const.ini and I’ve set simulation=true (was false).
(ramscan.txt not found)
Thank you. Regards. Alvise.
what driver?
.
Kodak i1200 series scanner.
ah. yeah there is a slightly different config for that driver.
if you open “%windir%twain_32kodakkds_i1200a shortcut to kds_i1200.lnk” you’ll find a const.ini. The relevant portion of mine looks like this:
[Simulation]
simulation=true
simmodel=i1220I haven’t been able to get the same level of simulation from the i1220. The models I mentioned offer a lot of features and while those simulation features may be available from the i1220 I don’t know how to configure them. My advise, test with the models I mentioned.
.
Hi Gabe, thanks for your response. I’ll start with i1210 and eventually will turn to i50.
Regards. Alvise.
Hi,
I tryed to set the duplex capability, but the return message is always failure (I tried with 2 different scanner),
anyway the setting has no effect on the acquisition.
I checked the duplex capability, and the aswer is success.
This is my code:
TwRC rc;
rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds);
if (rc != TwRC.Success) return;
//I set the multi-page capability
TwCapability cap = new TwCapability(TwCap.XferCount, -1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success) {
CloseSrc();
return; }
//I'm trying to disable the duplex
TwCapability capDuplex = new TwCapability(TwCap.CAP_DUPLEXENABLED,0);
//In this point I receive Failure
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capDuplexIs this code correct?
Do you have any suggestion?
Thank you@gabe wrote:
Right. You may want to check the return and condition codes further on your calls. You also may want to consider checking querysupport before setting the cap.
But more directly, it looks like you abort the scan if Any of the caps you are setting return anything but success. When you step thru this with your device, where does it exit?
Could be that for your device it returns when setting xfercount (not likely but possible), duplexEnabled (more likely – specially since you don’t seem to be checking whether or how duplex is supported first, I suspect this call the most), or even feederEnabled.I’m assuming that you are certain that the device supports duplex?
So step thru it, where does it return when intDuplex==1?, and what was the specific rc and cc?
And what are you using for a source?I’m going to guess this is based on netmasters code from codeproject, did you adjust the constructor for a new cap or are you using his code as-is?
gabe
- AuthorPosts