Re: Changing Xresolution and Yresolution
Started by nans at 05-14-2008 11:38. Topic has 5 replies.
|
|
05-14-2008, 11:38
|
nans
Joined on 04-30-2008
Posts 10
|
Changing Xresolution and Yresolution
|
 
 
|
|
|
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

Joined on 02-05-2007
Posts 202
|
Re: Changing Xresolution and Yresolution
|
 
 
|
|
|
|
|
|
05-15-2008, 8:14
|
nans
Joined on 04-30-2008
Posts 10
|
Re: Changing Xresolution and Yresolution
|
 
 
|
|
|
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

Joined on 08-22-2007
Posts 356
|
Re: Changing Xresolution and Yresolution
|
 
 
|
|
|
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
Joined on 04-30-2008
Posts 10
|
Re: Changing Xresolution and Yresolution
|
 
 
|
|
|
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

Joined on 08-22-2007
Posts 356
|
Re: Changing Xresolution and Yresolution
Attachment: tcTemp.png
|
 
 
|
|
|
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
|
|
|
|
|
LEAD Support Fo... » Developer » Scanning/Captur... » Re: Changing Xresolution and Yresolution
|
|
Copyright LEAD Technologies, Inc. 2008
