I created an application in WinForms that can list all the twain & wia scanners, and scan with the chosen device from that list.
Whenever i use TWAIN to scan without using the TWAIN user interface, i get images that are bad quality.
My code is based on the wrapper found here: https://www.codeproject.com/Articles/1376/NET-TWAIN-image-scanner?msg=1097187#xx1097187xx and the specifications at http://www.twain.org/wp-content/uploads/2016/03/TWAIN-2.2-Spec.pdf
I tried to set the resolution in dpi, but it doesn't make any difference. The rc always says "failure" after setting the cap:
TwFix32 f32 = new TwFix32();
f32.FromFloat(300);//value of DPI
// Set X resolution.
TwCapability capX = new TwCapability(TwCap.XResolution, f32.Whole);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capX);
// Set Y resolution.
TwCapability capY = new TwCapability(TwCap.YResolution, f32.Whole);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capY);