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

Question About ICAP_UNITS

Forums › TWAIN Classic › Question About ICAP_UNITS

  • This topic has 13 replies, 2 voices, and was last updated 13 years, 2 months ago by gabe.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • February 13, 2008 at 12:35 am #22286 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    If I were to set ICAP_UNITS to TWUN_PIXELS early on, is it safe to assume/expect that the data source will return values in pixels when querying things like ICAP_XRESOLUTION, ICAP_YRESOLUTION, etc etc?

    Thanks,

    Torin

    February 13, 2008 at 1:12 am #24334 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    The reason I ask is because I have a device where I set the units to pixels, then ask for the x and y resolutions, as well as ICAP_PHYSICALHEIGHT and ICAP_PHYSICALWIDTH. With the resolutions, I’m getting back an enumeration of 50 Fix32 values, some of which are negative, and some are REALLY small. Surely I’m missing something here right?

    Thanks,

    Torin

    February 13, 2008 at 11:01 am #24335 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    If I were to guess (and I’m about to) I’d say your fix32 is off and that you aren’t really getting negative values back from the device.
    I’m guessing this because I had the same trouble and it was an error on my part.
    For a test – run your code against a Kodak scanning in simulation mode as I am certain that they don’t return negative units.

    But as to your question, yes. if you set the units to xyx you should be getting responses for pretty much everything in xyx units except where noted otherwise in the spec. There are a couple of triplets that are documented as always returning in one unit or another – no I don’t remember exactly which ones (*should) always return in a certain unit but it’s in the spec.

    .

    February 13, 2008 at 2:50 pm #24336 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    Hard to say if it is correct or not. I have to think my code is correct because the first two values I get back are 800 and 600, and both of these are available in the data source’s UI. The following is the code where I’m enumerating the ICAP_YRESOLUTION values.


    TW_CAPABILITY twCapability;
    memset(&twCapability, 0, sizeof(twCapability));
    twCapability.Cap = ICAP_YRESOLUTION;
    twCapability.ConType = TWON_ENUMERATION;

    if ((Status = m_Twain.GetCapability(&twCapability)) != STATUS_SUCCESS)
    {
    return Status;
    }

    double dLargest = 0.0;
    pTW_ENUMERATION pEnum = reinterpret_cast(::GlobalLock(twCapability.hContainer));
    if (pEnum->ItemType != TWTY_FIX32)
    {
    ::GlobalUnlock(twCapability.hContainer);
    throw STATUS_NSTWAIN_UNSUPPORTED_DATA_TYPE;
    }
    else
    {
    double dTemp = 0.0;
    pTW_FIX32 pFixResolution = reinterpret_cast(pEnum->ItemList);
    TW_FIX32 FixResolution = { 0 };
    TW_UINT32 uiItemCounter = 0;
    for (uiItemCounter = 0; uiItemCounter < pEnum->NumItems; uiItemCounter++, pFixResolution++)
    {
    FixResolution = (*pFixResolution);

    dTemp = static_cast(FixResolution.Whole) + (static_cast(FixResolution.Frac) / 65536.0);
    if (dTemp > dLargest)
    {
    dLargest = dTemp;
    }
    }
    }
    ::GlobalUnlock(twCapability.hContainer);

    Due note, the negative and tiny values are seen in the FixResolution structure long before I do the conversion in to dTemp.

    Thanks,

    Torin

    February 13, 2008 at 3:32 pm #24337 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    Switching to getting a TW_RANGE appears to do what I want (as I only wanted the max and min). Is there documentation that explains how to interpret the results when using TW_ARRAY or TW_ENUMERATION?

    Thanks

    Torin

    February 13, 2008 at 4:23 pm #24338 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    if you want to test in the other direction – test the driver, run the twain toolkit against the device/driver. if the toolkit shows negative values then isn’t your code, plus you can compare your code against the toolkit if the toolkit shows positive. when my code had a problem it was as the return value would have approached X.5 – the closer it got to something and a half the further off my code got. but, check the toolkit. what device are you testing with?

    .

    February 13, 2008 at 4:28 pm #24339 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    The device I’m currently using is a Fujitsu fi-4340C, but I also saw similar behavior with a Lanier LD118D.

    Torin

    February 13, 2008 at 4:36 pm #24340 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    interesting, how do they look in the toolkit?

    .

    February 13, 2008 at 5:17 pm #24341 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    Looks like Twacker receives it as a range even when I set it to enumeration or array.

    Torin

    February 13, 2008 at 5:38 pm #24342 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    Wow. Amazing how different devices can be. What I’m trying to do is find the very largest image size in pixels that a device will provide. Yep, first thought is to get ICAP_PHYSICALHEIGHT and ICAP_PHYSICALWIDTH. Unfortunately, at least with the Fujitsu it is returning different values depending on the X/Y Resolution. So I figured I’d enumerate the X/Y Resolutions to find the maximum, set to the maximum, then get the physical height/width. Using Twacker, I can see that the Fujitsu returns bad value when trying to set the resolution with units set to pixels, but if I set units back to the inches that it defaults to, then set the resolutions it works fine. With the Lanier, it will allow me to set the units to pixels, then set the resolutions. What is the point of a spec/standard if no one is going to follow it? 🙂

    Torin

    February 13, 2008 at 6:03 pm #24343 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    Re-reading the spec helped since pixels per TWUN_PIXELS is meaningless.

    Torin

    February 13, 2008 at 7:37 pm #24344 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    but the values, are the values negative in the toolkit?

    February 13, 2008 at 7:44 pm #24345 Reply
    torinford
    Participant
    • Topics - 1
    • Replies - 8
    • Total Posts - 9

    Well since twacker is returning it as a range, they’re fine. Just like when my code requests them as a range. The problem showed up when requesting as an enumeration and twacker doesn’t return them as an enumeration.

    Torin

    February 13, 2008 at 8:00 pm #24346 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    Doesn’t seem to make sense that you’re getting a different container back for the same triplet with the same Msg,…
    What triplet are you sending / which Msg_Get (get,getCurrent or getDefault)?
    I can’t tell what Msg_Get* your m_Twain.GetCapability sends.

    And looking at the code fragment you sent, it doesn’t seem that you’re checking what container you were given, I see that you’re checking for the itemType and if the itemType == Fix or != but I don’t see where you verify the container type,.. is there more code where you switch on conType?

    .

  • Author
    Posts
Viewing 14 posts - 1 through 14 (of 14 total)
Reply To: Question About ICAP_UNITS
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.