TwainSetCurrentPixelType issue

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
ctn
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

TwainSetCurrentPixelType issue

Post by ctn » Thu Sep 03, 2009 4:39 pm

Hi

Event if Twain state is 4 (TWAIN_SOURCE_OPEN) it is sometimes not possible to set the pixel type at the "TwainSetCurrentPixelType" function:
setPictureConfigurationParameters(brightness=0, contrast=0, pictureModus=GREYSCALE): scanning set pixel types has been failed. twainResultCode=TWRC_FAILURE, twainStatus=TWAIN_SOURCE_OPEN, twainConditionCode=TWCC_BADVALUE
--> Result code: TWRC_FAILURE, Twain status: TWAIN_SOURCE_OPEN, Condition code = TWCC_BADVALUE

Code: Select all

				// Set pixel type
				// Default pixel type is blackwhite
				TwainPixelType pixelType = TwainPixelType.TWPT_BW;
				for(int i = 0; i < _pixelTypeValues.Length; i++)
				{
					if((int)pictureModus == _pixelTypeValues[i])
					{
						pixelType = TwainHandlerUtil.setPixelType(pictureModus);
						_pictureModus = pictureModus;
						break;
					}
				}

				if(!_gdTwain.TwainSetCurrentPixelType(pixelType))
				{
					setTwainStatus();
					_logger.logWarning("setPictureConfigurationParameters(brightness={0}, contrast={1}, pictureModus={2}): scanning set pixel types has been failed. "
					                   + "twainResultCode={3}, twainStatus={4}, twainConditionCode={5}", brightness, contrast, pictureModus, _twainResultCode, _twainStatus, _twainConditionCode);
				}
Can you tell me what the problem is?
Thank you
Br, ctn

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: TwainSetCurrentPixelType issue

Post by Loïc » Thu Sep 03, 2009 4:46 pm

Hi,

What is your scanner model ?

Kind regards,

Loïc

ctn
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: TwainSetCurrentPixelType issue

Post by ctn » Fri Sep 04, 2009 9:05 am

Hi Loïc

Im using serveral scanners like:

- plustek opticslim 500
- fujitsu fj-4120
- canon canoscan lide 200
- hp scanjet 5590
- etc.

But seems this behaviour is just available at plustek opticslim 500 scanner. Other scanners works fine.

Br, ctn

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: TwainSetCurrentPixelType issue

Post by Loïc » Fri Sep 04, 2009 10:09 am

Hi,

I guess it is a problem from your scanner driver. A workaround consist to use the TwainSetCapCurrentNumeric() method.

IE:

Code: Select all

Call Imaging1.TwainSetCapCurrentNumeric(ICAP_PIXELTYPE, Imaging1.TwainGetCapItemType(ICAP_PIXELTYPE), 1)

Note: ICAP_PIXELTYPE = 0x0101

Kind regards,

Loïc

ctn
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: TwainSetCurrentPixelType issue

Post by ctn » Mon Sep 07, 2009 10:08 am

Hi Loïc

This function "TwainSetCapCurrentNumeric" can not be called successfull as follow:

Code: Select all

// Set pixel type
				// Default pixel type is blackwhite
				TwainPixelType pixelType = TwainPixelType.TWPT_BW;
				for(int i = 0; i < _pixelTypeValues.Length; i++)
				{
					if((int)pictureModus == _pixelTypeValues[i])
					{
						pixelType = TwainHandlerUtil.setPixelType(pictureModus);
						_pictureModus = pictureModus;
						break;
					}
				}

				if(!_gdTwain.TwainSetCurrentPixelType(pixelType))
				{
					if (!_gdTwain.TwainSetCapCurrentNumeric(TwainCapabilities.ICAP_PIXELTYPE, _gdTwain.TwainGetCapItemType(TwainCapabilities.ICAP_PIXELTYPE), (int)pixelType))
					{
						setTwainStatus();
						_logger.logWarning("setPictureConfigurationParameters(brightness={0}, contrast={1}, pictureModus={2}): scanning set pixel types has been failed. "
						                   + "twainResultCode={3}, twainStatus={4}, twainConditionCode={5}", brightness, contrast, pictureModus, _twainResultCode, _twainStatus, _twainConditionCode);
					}
				}

I still get the following message:
setPictureConfigurationParameters(brightness=0, contrast=0, pictureModus=GREYSCALE): scanning set pixel types has been failed. twainResultCode=TWRC_FAILURE, twainStatus=TWAIN_SOURCE_OPEN, twainConditionCode=TWCC_BADVALUE
Could you please investigate?
Thank you
Br, ctn

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: TwainSetCurrentPixelType issue

Post by Loïc » Mon Sep 07, 2009 11:31 am

Hi,

Unfortunately I can't do anything else.

The driver of your scanner doesn't accept this value. Try to update it to a more recent version or contact the scanner manufacturer.

With best regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest