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

Set X / YResolution returned TWRC_CHECKSTATUS! Fujitsu C#

Forums › TWAIN Classic › Set X / YResolution returned TWRC_CHECKSTATUS! Fujitsu C#

  • This topic has 16 replies, 3 voices, and was last updated 13 years ago by black_ghost.
Viewing 15 posts - 1 through 15 (of 17 total)
1 2 →
  • Author
    Posts
  • June 14, 2007 at 7:18 pm #22159 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    Sorry I already do the Search but can’t find the answer!!

    I am trying to set the scanner’s Resolution (DPI) in C# with segment of codes below. My scanner is Fujitsu fi-5120C.


    …..

    TwFix32 f32 = new TwFix32();
    f32.FromFloat(X_DPI);
    tc = new TwCapability(TwCap.XResolution, f32.Whole);
    tc.ConType = (short)TwOn.One;
    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
    if (rc != TwRC.Success && rc != TwRC.CheckStatus)
    {
    CloseSrc();
    return;
    }

    f32.FromFloat(Y_DPI);
    tc = new TwCapability(TwCap.YResolution, f32.Whole);
    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
    if (rc != TwRC.Success && rc != TwRC.CheckStatus)
    {
    CloseSrc();
    return;
    }

    tc = new TwCapability(TwCap.IPixelType, (short)_ScanMode);
    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
    if (rc != TwRC.Success)
    {
    CloseSrc();
    return;
    }



    I have no problem to set the pixeltype and scan in duplex mode, but setting the resolutions to 600×600 failed.

    I tried this on other scanner and works fine, but not the Fujitsu scanner.

    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);

    The Fujitsu fi-5120c scanner returned this TwRC.CheckStatus
    The Brother MFC-7820N retuned TWRC.Success

    BTW: My computer is running Vista business. Tested both scanner on the same computer as well..

    June 15, 2007 at 9:55 am #23846 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    try to set that cap with twacker. if twacker can’t do it either, then it isn’t your code – it is entirely possible that the scanner doesn’t support setting that cap to that value… If you send a get for xresolution you often get the allowed values for the set operation – try setting to one of the value you recieve from the get op.

    What do you have for units when you are trying to set the resolution?
    And as with everything else, what is the condition code returned?

    June 15, 2007 at 1:59 pm #23847 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    @gabe wrote:

    try to set that cap with twacker. if twacker can’t do it either, then it isn’t your code – it is entirely possible that the scanner doesn’t support setting that cap to that value… If you send a get for xresolution you often get the allowed values for the set operation – try setting to one of the value you recieve from the get op.

    I just tried to set xResolution cap with Twacker..and it worked. I think something wrong with the type?

    In Twacker, the itemtype is TWTY_FIX32 and the value I set to 50 for X Resolution.

    If the value set to XResolution must be TWTY_FIX32, for my app it is the TwFix32 object.

    But, TwCapability() doesn’t take the twfix32 object as value. It only take the value in Short!

    TwFix32 f32 = new TwFix32();
    f32.FromFloat(50);
    tc = new TwCapability(TwCap.XResolution, f32.Whole);
    tc.ConType = (short)TwOn.One;
    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);

    rc will return CheckStatus. But Twacker tell me that the value can be set to the scanner!! Other CAP are alright, except this one taking the TwFix32 .

    I am not sure how to get the xresolution from the get op in the code. Can you give me a sample code?

    @gabe wrote:

    What do you have for units when you are trying to set the resolution?
    And as with everything else, what is the condition code returned?

    I tried to set the units to pixels and got success returned!

    tc = new TwCapability(TwCap.IUnits, (short)TwUn.PIXELS);
    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);

    June 15, 2007 at 3:10 pm #23848 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    so it sounds like your scanner will take the value,
    good (thank you twacker)

    if you’re unable to send a fix32 to your twCap it sounds like you need to work over your twain library a bit, which brings up a question – how are you talking to twain from c#? are you using a library you write or the library you found on codeproject by netMaster?

    to get the values for the cap you send get instead of set in the op and then read the values it puts in the container that you sent in (mostly)

    a condition code is like a return code except is describes (in most cases) why you recieved the preious return code – I typically only check the cc when the previous call produced an rc != success. read through the twain spec for more on that… hell read through the twain spec regardless. then read though it again.

    do I have code for setting the xresolution… yes and no. I don’t take the setting caps one-by-one approach (I believe it is a flawed design for working with twain), but I can probably find some code to approximate what you’re doing. first, lets talk about your library and then how you defined you twCap class. I have something of an example for the twCap class if you’re using the 2.0 framework and either read vb.net or have a decent converter (sharpdevelop 2.1 comes to mind if you want to convert it to c#) the code is over at http://www.codeplex.com/opentwain. you won’t find xresolution setting in the class but you can compare the twCap class.

    .

    June 15, 2007 at 3:36 pm #23849 Reply
    Anonymous
    Participant
    • Topics - 60
    • Replies - 107
    • Total Posts - 167

    @gabe wrote:

    so it sounds like your scanner will take the value,
    good (thank you twacker)

    if you’re unable to send a fix32 to your twCap it sounds like you need to work over your twain library a bit, which brings up a question – how are you talking to twain from c#? are you using a library you write or the library you found on codeproject by netMaster?

    Yes, download from codeproject! so I should make the fix32 send to twCap right? the code from netMaster, never have that part done!!

    @gabe wrote:

    to get the values for the cap you send get instead of set in the op and then read the values it puts in the container that you sent in (mostly)

    a condition code is like a return code except is describes (in most cases) why you recieved the preious return code – I typically only check the cc when the previous call produced an rc != success. read through the twain spec for more on that… hell read through the twain spec regardless. then read though it again.

    do I have code for setting the xresolution… yes and no. I don’t take the setting caps one-by-one approach (I believe it is a flawed design for working with twain), but I can probably find some code to approximate what you’re doing. first, lets talk about your library and then how you defined you twCap class. I have something of an example for the twCap class if you’re using the 2.0 framework and either read vb.net or have a decent converter (sharpdevelop 2.1 comes to mind if you want to convert it to c#) the code is over at http://www.codeplex.com/opentwain. you won’t find xresolution setting in the class but you can compare the twCap class.
    .[/quote]

    I got OpenTwain already.. looks like it is not complete!
    so you suggest I should look at it?

    Thanks!!

    June 15, 2007 at 8:22 pm #23850 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    openTwain its not complete in the sense that there are more to do – seems like there always is. Buffered memory transfers aren’t in there and I like to finish fleshing out the standard caps so that they take the appropriate params and types and expose the ops supported appropriately. In the current build you have to build up each of the caps the same way you do with netmaster code and I don’t think that is a particuarly useful design. The parts that are there work and are stable. the parts that don’t work should all be commented as ‘not live’ and you’ll find the classes there empty.
    Do I suggest you look at it… it may help. it is based on netmasters code. I added the rest of the enumerations, cc checking, a custom message loop so that you don’t have to modify your message loop in you app – just handle the events from the library, added tracking for the twState and fixed a problem he had with his transitions. added ImageInfo and ExtImageInfo checking…

    look at the constructors for twCapability it should look something more like opentwain in that the size of memory reserved should depend on the cap coming in , if I remember right he hard coded a number that should be looked up. [EDITED: the value he hardcoded was the size of memory to allocate for the container – the method I use to determine the size is named ‘m_itemSizeOf’ – you’ll find it in DataStructures.vb, in the twCapability classs, his method will fail for several of the standard caps] I’ll look back over my notes from when I did the first couple reviews to see is there was anything else in his code that I tripped up on.

    and don’t get me wrong, his code is brilliant – especially in the sense that there really didn’t exist (m)any alternatives for people that wanted to talk directly to twain from .net without buying a library – but at the same time, as he says in the article it is mostly a demonstration of interop not twain.

    if you have questions just ask, I’m fairly familliar with netMasters code.

    .

    February 18, 2008 at 3:43 pm #23851 Reply
    black_ghost
    Participant
    • Topics - 1
    • Replies - 14
    • Total Posts - 15

    Where can I find DataStructures.vb? I’m looking for it, becaues I’m also working with NetMaster’s code and I’ve got hardcoded size of memory.

    February 18, 2008 at 10:39 pm #23852 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    2 posts (3 if you count this one) i post a link to opentwain. then in follow the directory tree down to .openTwainTwainDataStructures and you’ll see the .vb file

    February 19, 2008 at 1:59 pm #23853 Reply
    black_ghost
    Participant
    • Topics - 1
    • Replies - 14
    • Total Posts - 15

    The page cannot be found
    The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

    Any ideas? 🙂

    February 20, 2008 at 6:41 am #23854 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    what page? it’s a file. you download the zip file. you open the zip file, then you go down a couple directories,..

    .

    February 21, 2008 at 12:41 pm #23855 Reply
    black_ghost
    Participant
    • Topics - 1
    • Replies - 14
    • Total Posts - 15

    OK, sorry, my fault.

    February 23, 2008 at 10:47 am #23856 Reply
    black_ghost
    Participant
    • Topics - 1
    • Replies - 14
    • Total Posts - 15

    Will be in VB.NET and C# the size of data types the same?

    February 23, 2008 at 10:54 am #23857 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    yes, slightly different signatures, declarations between c# and vb.net, but the the common type system (CTS) is a fundamental part of the common runtime language (CLR) for all .net languages.

    .

    February 23, 2008 at 10:57 am #23858 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    and if you’re looking for a simple converter (c# <-> vb.net) it seems to me that #develop does the best job – http://www.icsharpcode.net/

    .

    February 23, 2008 at 11:05 am #23859 Reply
    black_ghost
    Participant
    • Topics - 1
    • Replies - 14
    • Total Posts - 15

    ok, but can you tell me, why is someone (you?) add to each size of data type OneValue.baseSize (I’m talking about DataStructures.vb)?

    I’m asking, because I’m trying fix the constructor of cTwCapability in NetMaster’s code.

  • Author
    Posts
Viewing 15 posts - 1 through 15 (of 17 total)
1 2 →
Reply To: Set X / YResolution returned TWRC_CHECKSTATUS! Fujitsu C#
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

  • could not open the twain source. Make sure there is a valid source for your sca
  • Changing TWAIN driver defaults
  • Scanner starts transfer when console gets closed (CITRIX)
  • Kodak RFS 3600
  • Didn’t save enough file scan
  • 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.