title: Setting resolution for TWAIN scanning
body: <p>I created an application in WinForms that can list all the twain &amp; wia scanners, and scan with the chosen device from that list.</p>
  
  <p>Whenever i use TWAIN to scan without using the TWAIN user interface, i get images that are bad quality.</p>
  
  <p>My code is based on the wrapper found here: <a href="https://www.codeproject.com/Articles/1376/NET-TWAIN-image-scanner?msg=1097187#xx1097187xx" rel="nofollow noreferrer">https://www.codeproject.com/Articles/1376/NET-TWAIN-image-scanner?msg=1097187#xx1097187xx</a> and the specifications at <a href="http://www.twain.org/wp-content/uploads/2016/03/TWAIN-2.2-Spec.pdf" rel="nofollow noreferrer">http://www.twain.org/wp-content/uploads/2016/03/TWAIN-2.2-Spec.pdf</a></p>
  
  <p>I tried to set the resolution in dpi, but it doesn't make any difference. The rc always says "failure" after setting the cap:</p>
  
  <pre><code>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);
  </code></pre>