Home › Forums › TWAIN Classic › How to set the resolution (DPI)? › Reply To: How to set the resolution (DPI)?
@gabe wrote:
When you’re setting resolution you should check what the units (ICAP_UNITS) are set to first – 499 x 499 pixels isn’t quite the same as 499×499 cm. See the capability ordering whitepaper for information on the order to set capabilities – http://twain.org/docs/CapOrderForWeb.PDF
You also may want to check the supported resolution(s) with a Get before trying the Set, some devices will round to the nearest supported and others with simply disregard your setting – recheck executeing the Get op for the resolution after you execute the set should assure you that you have successfully set the capability.
When you set the resolution are you getting an rc=success from the triplet?
.
I am using JTwain (Java) so I don’t know what “rc” is. Is it from the .NET implementation? Here is the code I am executing and the output. I tried setting the units before the resolution but it still doesn’t work.
Source source = SourceManager.instance().selectSourceByName("HP Scanjet G3010 TWAIN");
source.open();
if (source.isUIEnabled()) {
source.setUIEnabled(false);
}
source.setIndicators(false);
System.out.println("============= BEFORE SETTING =============");
System.out.println("bit depth: " + source.getCurrentBitDepth());
System.out.println("units: " + source.getCurrentUnits()[0]);
System.out.println("pixel type: " + source.getCurrentPixelType());
System.out.println("x res: " + source.getCurrentXResolution());
System.out.println("y res: " + source.getCurrentYResolution());
source.setMinimumExceptionEnabled(false);
source.setRegion(0,0,source.getCurrentPhyscialWidth(),source.getPhysicalHeight());
source.setUnits(JTwainConstants.TWUN_PIXELS);
source.setPixelType(JTwainConstants.TWPT_GRAY);
source.setXResolution(300.0);
source.setYResolution(300.0);
source.setBitDepth(8);
System.out.println("n" + "============= AFTER SETTING =============");
System.out.println("bit depth: " + source.getCurrentBitDepth());
System.out.println("units: " + source.getCurrentUnits()[0]);
System.out.println("pixel type: " + source.getCurrentPixelType());
System.out.println("x res: " + source.getCurrentXResolution());
System.out.println("y res: " + source.getCurrentYResolution());
source.acquireImage();
source.saveLastAcquiredImageIntoFile("c:\temp\scan.JPG");
============= BEFORE SETTING =============
bit depth: 8
units: 0
pixel type: 2
x res: 200.0
y res: 200.0
============= AFTER SETTING =============
bit depth: 8
units: 5
pixel type: 1
x res: 1.0
y res: 1.0
It looks like the scanner ignores the values and sets x res and y res to 1.0??!!
But the scanned image file properties show that it has 96 dpi.