Home › Forums › TWAIN Classic › Brightness Problem with Hp8200
- This topic has 5 replies, 4 voices, and was last updated 14 years, 4 months ago by Kaij.
- AuthorPosts
I am trying to run the test application of twain. (Version:2.0.8 , downloaded from twain.org)
The test application has the functions to set resolution, bits per pixel etc.
When I tried to set the brightness I could not able to do it.
Below is my code for setting brightness (in VC++)
BOOL CTwain::SetBrightness(TW_INT16 brightness)
{
TW_CAPABILITY twCapability;//Setup TW_CAPABILITY Structure
twCapability.Cap = ICAP_BRIGHTNESS;
twCapability.ConType = TWON_ONEVALUE;
pTW_ONEVALUE pvalOneValue;twCapability.hContainer = GlobalAlloc(GHND, sizeof(TW_ONEVALUE));
pvalOneValue = (pTW_ONEVALUE)GlobalLock(twCapability.hContainer);if (!pvalOneValue)
return FALSE;pvalOneValue->ItemType = TWTY_FIX32;
TW_FIX32* pItem;
pItem = (TW_FIX32*)(&(pvalOneValue->Item));
pItem->Whole = brightness;
pItem->Frac = 0;GlobalUnlock(twCapability.hContainer);
if(CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_CAPABILITY,MSG_SET,(TW_MEMREF)&twCapability))
return TRUE;GlobalFree(twCapability.hContainer);
return FALSE;
}BOOL CTwain::CallTwainProc(pTW_IDENTITY pOrigin,pTW_IDENTITY pDest, TW_UINT32 DG,TW_UINT16 DAT,TW_UINT16 MSG, TW_MEMREF pData)
{
DSMENTRYPROC m_pDSMProc;
if(!(m_pDSMProc = (DSMENTRYPROC)GetProcAddress(m_hTwainDLL,MAKEINTRESOURCE(1))))
{
FreeLibrary(m_hTwainDLL);
m_hTwainDLL = NULL;
}
if(IsValidDriver())
{
USHORT ret_val;
ret_val = (*m_pDSMProc)(pOrigin,pDest,DG,DAT,MSG,pData);
m_returnCode = ret_val;
if(ret_val != TWRC_SUCCESS)
{
(*m_pDSMProc)(pOrigin,pDest,DG_CONTROL,DAT_STATUS,MSG_GET,&m_Status);
}
return (ret_val == TWRC_SUCCESS);
}
else
{
m_returnCode = TWRC_FAILURE;
return FALSE;
}
}The CallTwainProc() is returning false. Hence setting brightness is not affected.
Would be thankful for quick reply
Not sure what is going wrong in CallTwainProc
But at the end of your SetBrightness function you are not freeing memory on success.
if(CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_CAPABILITY,MSG_SET,(TW_MEMREF)&twCapability))
return TRUE;
GlobalFree(twCapability.hContainer);
return FALSE;
}Jim Watters
Dear Watters,
Thank you. I feel freeing the memory is not causing the brightness setting problem. It may crash if there is memory leak.
I don’t know why CallTwainProc is getting failed(returning false).
Please suggest if any changes required in the sample code.Did you check whether this scanner supports setting ICAP_BRIGHTNESS?
How do I check whether my scanner supports ICAP_BRIGHTNESS.
You can check it with TWACKER from TWAIN Working Group in special menu.
Best regards,
Kaij
- AuthorPosts