I m using plustek OpticSlim500 scanner and sometimes I do get this during TwainSetImageLayout.
This is my error message:
My code look like:scanningSetRegion(left=0, top=0, right=8.26, bottom=11.69): default scan region (inches) could not be set: defaultLeft=0, defaultTop=0, defaultRight=8.5, defaultBottom=5.509994. TwainGetLastResultCode=TWRC_FAILURE, TwainGetState()=TWAIN_TRANSFER_READY, TwainGetLastConditionCode=TWCC_BADPROTOCOL
Code: Select all
public void scanningSetRegion(double left, double top, double right, double bottom)
{
...
...
if((left < right) && (top < bottom))
{
if(_gdTwain.TwainSetImageLayout(left, top, right, bottom))
{
_logger.logDebug("scanningSetRegion(left={0}, top={1}, right={2}, bottom={3}): set region has been done.", left, top, right, bottom);
_regionLeft = left;
_regionTop = top;
_regionRight = right;
_regionBottom = bottom;
}
else
{
_logger.logWarning("scanningSetRegion(left={0}, top={1}, right={2}, bottom={3}): set default region has been done.", left, top, right, bottom);
if(!_gdTwain.TwainSetImageLayout(_defaultRegionLeft, _defaultRegionTop, _defaultRegionRight, _defaultRegionBottom))
{
TwainResultCode twainResultCode = _gdTwain.TwainGetLastResultCode();
TwainStatus twainStatus = _gdTwain.TwainGetState();
TwainConditionCode twainConditionCode = _gdTwain.TwainGetLastConditionCode();
_logger.logWarning("scanningSetRegion(left={0}, top={1}, right={2}, bottom={3}): default scan region (inches) could not be set: defaultLeft={4}, defaultTop={5}, defaultRight={6}, defaultBottom={7}. TwainGetLastResultCode={8}, TwainGetState()={9}, TwainGetLastConditionCode={10}", left, top, right, bottom, _defaultRegionLeft, _defaultRegionTop, _defaultRegionRight, _defaultRegionBottom, twainResultCode, twainStatus, twainConditionCode);
}
}
}
else
{
// throw new Exception
}
...
...
}
Normally I got this error after calling scanningSetRegion a 2nd time. This just happened after calling _gdTwain.TwainAcquireToGdPictureImage(0) if I call scanningSetRegion before acquire the image I won't get any error.
Could you please help?
Thanks
Br, ctn