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

C# Get and Set DPI Resolution

Forums › TWAIN Classic › C# Get and Set DPI Resolution

  • This topic has 2 replies, 2 voices, and was last updated 8 years, 4 months ago by damiano.canonico.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • September 18, 2012 at 12:41 pm #22779 Reply
    damiano.canonico
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    Hi, I developed an application that scans documents using various scanners and each time I have to show the scanner setting form (ShowUI=1).
    I’d like to gather the information about the scanning resolution set, save them and rewrite them next time the software is launched.
    I’ve read something around and came up to the following code:

    [DllImport(“twain_32.dll”, EntryPoint = “#1”)]
    private static extern TwRC DSM_Entry([In, Out] TwIdentity origin, IntPtr zeroptr, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TwIdentity idds);

    TwRC rc1 = DSM_Entry(appid, IntPtr.Zero, TwDG.Control, TwDAT.Capability, TwMSG.GetCurrent, srcds);

    run just after the scan procedure in the standard TwainLib.cs (appid and srcds are filled as usual) but any time ti gives me failure
    I Tested also the following code to set the resolution:

    TwRC rc1;
    TwCapability tc;
    TwFix32 f32 = new TwFix32();
    f32.FromFloat(100);//value of DPI
    tc = new TwCapability(TwCap.IXResolution, f32.Whole);
    rc1 = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
    if (rc1 != TwRC.Success)
    {
    CloseSrc();
    return ;
    }

    But it also gives me a TwRC.Failure

    Can somebody help me please?

    P.S. The scanner I’m using is an HP ScanJet 7650 (maybe it has to do with the scanner)

    September 18, 2012 at 7:13 pm #25691 Reply
    Erin Dempsey
    Participant
    • Topics - 6
    • Replies - 26
    • Total Posts - 32

    Hello,

    The scanner you are using does not support 100 DPI. Our group suggests that you try using 150.

    Best regards,
    Hilary Minugh
    TWAIN Administrator

    September 19, 2012 at 6:21 am #25692 Reply
    damiano.canonico
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    OK…I was able to use the Get, I took away to another function the all procedure that now is:

    f32.FromFloat(value of DPI );//value of DPI
    tc = new TwCapability(TwCap.IXResolution, f32.Whole);
    Init(hwnd);
    rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds);

    rc1 = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.GetCurrent, tc);
    if (rc1 == TwRC.Success)
    {
    Tw_Enum twResolutions = (Tw_Enum)Marshal.PtrToStructure(GlobalLock(tc.Handle), typeof(Tw_Enum));
    }
    rc1 = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);

    Now the TwMSG.Set works (I’m using its value) but I have strange values in the twResolutions fields:

    CurrentIndex=0
    DefaultIndex=108
    ItemType=7
    NumItem=300
    ItemList is an array of 100 values with stranger values

    If I use the TwMSG.Get I have in twResolutions :

    CurrentIndex=0
    DefaultIndex=600
    ItemType=7
    NumItem=50
    ItemList is an array of 100 values with stranger values

    I’m not able to understand how to use one of this values other than set the current value for the resolution
    Any Help??

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: C# Get and Set DPI Resolution
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

  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • To get the list of scanners from javascript client side (browser)
  • 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.