Loading...

TwainSetImageLayout: TWCC_BADPROTOCOL

Support for GdTwain ActiveX and GdTwain Pro ActiveX/SDK.

TwainSetImageLayout: TWCC_BADPROTOCOL

Postby ctn » Mon Jul 27, 2009 4:54 pm

Hi

I m using plustek OpticSlim500 scanner and sometimes I do get this during TwainSetImageLayout.

This is my error message:
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


My code look like:
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
ctn
 
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: TwainSetImageLayout: TWCC_BADPROTOCOL

Postby Loïc » Tue Jul 28, 2009 5:33 pm

Hi,

From the reference guide:
Before using this function check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() function.


Are you in state 4 ? :wink:

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: TwainSetImageLayout: TWCC_BADPROTOCOL

Postby ctn » Wed Jul 29, 2009 2:28 pm

Hi

Thanks. The issue has been solved. :)
Br, ctn
ctn
 
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm


Return to GdTwain [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 2 guests