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

Error in setting ICAP_BITDEPTHREDUCTION

Forums › TWAIN Classic › Error in setting ICAP_BITDEPTHREDUCTION

  • This topic has 2 replies, 2 voices, and was last updated 13 years, 9 months ago by gabe.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 11, 2007 at 10:07 am #22136 Reply
    albertmaxim
    Participant
    • Topics - 2
    • Replies - 3
    • Total Posts - 5

    Hi,

    I am able to set the capability ICAP_BITDEPTHREDUCTION when using the scanner like HP Commericial Scanjet 5590 Twain
    and Hp PSC1410 All-in-one series. But when using Canon scanner canoscan LIDE70, i am able to set the capability ICAP_BITDEPTHREDUCTION

    I am getting the error while setting the Mode [mode is either black & white or gray scale or color].
    Please find the sample piece of code to set mode for the selected source / scanner.

    BOOL ret_value = FALSE;
    TW_CAPABILITY twCapability;
    TW_UINT32 NumberOfItems;
    pTW_ENUMERATION pvalEnum;
    twCapability.Cap = ICAP_PIXELTYPE;
    twCapability.ConType = TWON_ENUMERATION;//TWON_ONEVALUE, TWON_RANGE, TWON_ENUMERATION or TWON_ARRAY
    NumberOfItems = 1;
    twCapability.hContainer = GlobalAlloc(GHND,(sizeof(TW_ENUMERATION) + sizeof(TW_UINT16) * (NumberOfItems)));
    if(twCapability.hContainer)
    {
    pvalEnum = (pTW_ENUMERATION)GlobalLock(twCapability.hContainer);
    pvalEnum->NumItems = (TW_UINT32)NumberOfItems;
    pvalEnum->ItemType = TWTY_UINT16;
    pvalEnum->ItemList[0] = TWPT_BW;
    pvalEnum->CurrentIndex = 0;
    pvalEnum->DefaultIndex = TWON_DONTCARE32;
    GlobalUnlock(twCapability.hContainer);
    ret_value=SetCapability(twCapability);
    GlobalFree(twCapability.hContainer);

    if(ret_value)
    {
    twCapability.Cap = ICAP_BITDEPTHREDUCTION;
    twCapability.ConType = TWON_ONEVALUE;
    pTW_ONEVALUE pVal;

    twCapability.hContainer = GlobalAlloc(GHND,sizeof(TW_ONEVALUE));
    if(twCapability.hContainer)
    {
    pVal = (pTW_ONEVALUE)GlobalLock(twCapability.hContainer);
    pVal->ItemType = TWTY_UINT16;
    pVal->Item = TWBR_THRESHOLD;
    GlobalUnlock(twCapability.hContainer);
    ret_value = SetCapability(twCapability);
    GlobalFree(twCapability.hContainer);
    }
    return ret_value;
    }
    }//end of if (twCap.hContainer)

    Please provide me a solution for this error.

    May 11, 2007 at 10:10 am #23779 Reply
    albertmaxim
    Participant
    • Topics - 2
    • Replies - 3
    • Total Posts - 5

    @albertmaxim wrote:

    Hi,

    I am able to set the capability ICAP_BITDEPTHREDUCTION when using the scanner like HP Commericial Scanjet 5590 Twain
    and Hp PSC1410 All-in-one series. But when using Canon scanner canoscan LIDE70, i am not able to set the capability ICAP_BITDEPTHREDUCTION

    I am getting the error while setting the Mode [mode is either black & white or gray scale or color].
    Please find the sample piece of code to set mode for the selected source / scanner.

    BOOL ret_value = FALSE;
    TW_CAPABILITY twCapability;
    TW_UINT32 NumberOfItems;
    pTW_ENUMERATION pvalEnum;
    twCapability.Cap = ICAP_PIXELTYPE;
    twCapability.ConType = TWON_ENUMERATION;//TWON_ONEVALUE, TWON_RANGE, TWON_ENUMERATION or TWON_ARRAY
    NumberOfItems = 1;
    twCapability.hContainer = GlobalAlloc(GHND,(sizeof(TW_ENUMERATION) + sizeof(TW_UINT16) * (NumberOfItems)));
    if(twCapability.hContainer)
    {
    pvalEnum = (pTW_ENUMERATION)GlobalLock(twCapability.hContainer);
    pvalEnum->NumItems = (TW_UINT32)NumberOfItems;
    pvalEnum->ItemType = TWTY_UINT16;
    pvalEnum->ItemList[0] = TWPT_BW;
    pvalEnum->CurrentIndex = 0;
    pvalEnum->DefaultIndex = TWON_DONTCARE32;
    GlobalUnlock(twCapability.hContainer);
    ret_value=SetCapability(twCapability);
    GlobalFree(twCapability.hContainer);

    if(ret_value)
    {
    twCapability.Cap = ICAP_BITDEPTHREDUCTION;
    twCapability.ConType = TWON_ONEVALUE;
    pTW_ONEVALUE pVal;

    twCapability.hContainer = GlobalAlloc(GHND,sizeof(TW_ONEVALUE));
    if(twCapability.hContainer)
    {
    pVal = (pTW_ONEVALUE)GlobalLock(twCapability.hContainer);
    pVal->ItemType = TWTY_UINT16;
    pVal->Item = TWBR_THRESHOLD;
    GlobalUnlock(twCapability.hContainer);
    ret_value = SetCapability(twCapability);
    GlobalFree(twCapability.hContainer);
    }
    return ret_value;
    }
    }//end of if (twCap.hContainer)

    Please provide me a solution for this error.

    May 12, 2007 at 7:52 am #23780 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    If I were you I would start by declaring retval (usually refered to as rc) differently – it isn’t as simple as a bool.
    then if you’re getting an rc != success you should check the conditioncode cc. in the twain spec look at chapter 10 ‘return codes and condition codes’

    then post the appropriate rc and cc you’re getting and if you’re still unsure post back.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Reply #23780 in Error in setting ICAP_BITDEPTHREDUCTION
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

  • Scanner starts transfer when console gets closed (CITRIX)
  • Kodak RFS 3600
  • Didn’t save enough file scan
  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • 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.