TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Please tell me how Duplex scanning with C# program?

Forums › TWAIN Classic › Please tell me how Duplex scanning with C# program?

  • This topic has 18 replies, 4 voices, and was last updated 12 years, 6 months ago by gabe.
Viewing 15 posts - 1 through 15 (of 19 total)
1 2 →
  • Author
    Posts
  • March 20, 2006 at 7:37 am #21900 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    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!

    March 20, 2006 at 2:26 pm #23272 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    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

    March 21, 2006 at 1:07 am #23273 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    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;
    }
    }

    March 21, 2006 at 8:07 am #23274 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    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

    March 21, 2006 at 9:01 am #23275 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    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!

    March 21, 2006 at 9:26 am #23276 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    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

    March 22, 2006 at 1:54 am #23277 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    Thank Gabe very much!
    I will try it.

    March 22, 2006 at 3:07 am #23278 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    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!

    March 22, 2006 at 7:24 am #23279 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    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

    May 6, 2008 at 8:42 am #23280 Reply
    alvise
    Participant
    • Topics - 10
    • Replies - 23
    • Total Posts - 33

    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.

    May 7, 2008 at 10:02 am #23281 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    what driver?

    .

    May 7, 2008 at 10:26 am #23282 Reply
    alvise
    Participant
    • Topics - 10
    • Replies - 23
    • Total Posts - 33

    Kodak i1200 series scanner.

    May 7, 2008 at 3:32 pm #23283 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    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=i1220

    I 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.

    .

    May 7, 2008 at 3:48 pm #23284 Reply
    alvise
    Participant
    • Topics - 10
    • Replies - 23
    • Total Posts - 33

    Hi Gabe, thanks for your response. I’ll start with i1210 and eventually will turn to i50.

    Regards. Alvise.

    October 15, 2008 at 1:46 pm #23285 Reply
    SerenaFab
    Participant
    • Topics - 0
    • Replies - 2
    • Total Posts - 2

    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, capDuplex

    Is 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

  • Author
    Posts
Viewing 15 posts - 1 through 15 (of 19 total)
1 2 →
Reply To: Reply #23274 in Please tell me how Duplex scanning with C# program?
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • TWAIN for dental imaging integration
  • PDF/R For who and where?
  • Making searchable PDF with PDF/R
  • Backward compatibility with PDF/A and traditional PDF
  • could not open the twain source. Make sure there is a valid source for your sca
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.