Home › Forums › TWAIN Classic › Error in setting ICAP_BITDEPTHREDUCTION
- This topic has 2 replies, 2 voices, and was last updated 16 years, 10 months ago by gabe.
- AuthorPosts
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_BITDEPTHREDUCTIONI 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.
@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_BITDEPTHREDUCTIONI 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.
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.
- AuthorPosts