Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Changing Xresolution and Yresolution
Started by nans at 05-14-2008 11:38. Topic has 5 replies.

Print Search « Previous Thread Next Thread »
  05-14-2008, 11:38
nans is not online. Last active: 6/13/2008 1:27:14 PM nans

Top 500 Posts
Joined on 04-30-2008
Posts 10
Changing Xresolution and Yresolution
Reply Quote
Hi all,

I use leadtools v15.
I have a problem to change Xresolution and Yresolution before scanning.

Here my code :
---------------------------------------
TwainCapability tcDPI = new TwainCapability();
tcDPI.Information.ContainerType = TwainContainerType.OneValue;
tcDPI.Information.Type = TwainCapabilityType.ImageXResolution;
tcDPI.OneValueCapability.ItemType = TwainItemType.Fix32;
tcDPI.OneValueCapability.Value = 150;
_twainSession.SetCapability(tcDPI, TwainSetCapabilityMode.Set);
tcDPI.Information.ContainerType = TwainContainerType.OneValue;
tcDPI.Information.Type = TwainCapabilityType.ImageYResolution;
tcDPI.OneValueCapability.ItemType = TwainItemType.Fix32;
tcDPI.OneValueCapability.Value = 150;
_twainSession.SetCapability(tcDPI, TwainSetCapabilityMode.Set);
---------------------------------------

I don't understand but the resolution doesn't change :'(

Thanks.


   Report 
  05-15-2008, 5:37
Yasir Alani is not online. Last active: 11/16/2008 11:29:23 AM Yasir Alani



Top 10 Posts
Joined on 02-05-2007
Posts 311
Re: Changing Xresolution and Yresolution
Reply Quote

Your code appears to be correct.

 

Are you sure the Twain driver of the scanner supports setting the DPI resolution? You can verify that using the Twacker utility.

 

If you don't have it or haven't used it before, see this forum post for details:

http://support.leadtools.com/SupportPortal/cs/forums/3781/ShowPost.aspx


Yasir Alani
LEADTOOLS Technical Support
support@leadtools.com
   Report 
  05-15-2008, 8:14
nans is not online. Last active: 6/13/2008 1:27:14 PM nans

Top 500 Posts
Joined on 04-30-2008
Posts 10
Re: Changing Xresolution and Yresolution
Reply Quote
I verify using Twacker utility and that is good,the scanner supports setting the DPI resolution.

So have you an idea where is the problem?
I don't understand.

   Report 
  05-15-2008, 11:30
jigar is not online. Last active: 11/19/2008 5:21:33 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 453
Re: Changing Xresolution and Yresolution
Reply Quote
Hello,

A simpler way of doing it is to set TwainSession.Properties.ImageResolution.HorizontalResolution and TwainSession.Properties.ImageResolution.VerticalResolution.

See if that works.  If it does then it's probably the tcDPI.OneValueCapability.ItemType value you are setting.  Try setting it to TwainItemType.Int32 or TwainItemType.Int16.  Sometimes the value types are not as expected.

LEADTOOLS Technical Support
   Report 
  05-16-2008, 4:25
nans is not online. Last active: 6/13/2008 1:27:14 PM nans

Top 500 Posts
Joined on 04-30-2008
Posts 10
Re: Changing Xresolution and Yresolution
Reply Quote
Even if i put TwainSession.Properties.ImageResolution.HorizontalResolution and TwainSession.Properties.ImageResolution.VerticalResolution, the problem is always the same.
When i change tcDPI.OneValueCapability.ItemType there is an error : InvalidCapability value on _twainSession.SetCapability(tcDPI, TwainSetCapabilityMode.Set);

Here the code i change :
---------------------------
bool twainAvailable = TwainSession.IsAvailable(this);
if (twainAvailable)
{
_twainSession = new TwainSession();
_twainSession.Startup(this, "", "", "", "", TwainStartupFlags.None);
_twainSession.EnableSetPropertyEvent = true;
TwainProperties props = _twainSession.Properties;
TwainImageResolutionProperties imageres = props.ImageResolution;

TwainCapability tcDPI = new TwainCapability();
tcDPI.Information.ContainerType = TwainContainerType.OneValue;
tcDPI.Information.Type = TwainCapabilityType.ImageXResolution;
tcDPI.OneValueCapability.ItemType = TwainItemType.Fix32;
tcDPI.OneValueCapability.Value = 75;
_twainSession.SetCapability(tcDPI, TwainSetCapabilityMode.Set);
tcDPI.Information.ContainerType = TwainContainerType.OneValue;
tcDPI.Information.Type = TwainCapabilityType.ImageYResolution;
tcDPI.OneValueCapability.ItemType = TwainItemType.Fix32;
tcDPI.OneValueCapability.Value = 75;
_twainSession.SetCapability(tcDPI, TwainSetCapabilityMode.Set);

imageres.HorizontalResolution = 75;
imageres.VerticalResolution = 75;
props.ImageResolution = imageres;
_twainSession.Properties = props;
_twainSession.EnableAcquireMultiPageEvent = true;
_twainSession.AcquireMultiPage += new EventHandler(twain_AcquireMulti);
_twainSession.AcquireFast(_fileName,
TwainFastUserInterfaceFlags.Show,
TwainTransferMode.Buffer,
RasterImageFormat.RasPdfJpeg, 24, true, 0, true);
_twainSession.Shutdown();

----------------------------------


   Report 
  05-21-2008, 12:00
jigar is not online. Last active: 11/19/2008 5:21:33 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 453
Re: Changing Xresolution and Yresolution

Attachment: tcTemp.png
Reply Quote
That's odd.  What scanner do you have?  "InvalidCapability Value" means the scanner is saying that the value you are specifying is not acceptable.  Try doing:

TwainCapability tcTemp = session.GetCapability(TwainCapabilityType.ImageXResolution, TwainGetCapabilityMode.GetValues);

Check the values of tcTemp to see what they return.  For me it returned a Range type value.  Check my screenshots for the values.  So as long as I stay in that range, and my values are the valid steps (value % 10 == 0), then it will work fine.


LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » Developer » Scanning/Captur... » Changing Xresolution and Yresolution

Powered by Community Server, by Telligent Systems