0

I am very new to Qt and right now we are developing an application that is using the TWAIN library to control a scanner.

By default, we assumed that the DPI setting of the scanner is set to 300. However, if by chance, the user manually sets the scanner's DPI to 600 in the device settings, our application has to adjust accordingly.

Is there any way to know the DPI setting of the scanner internally through TWAIN? Like know what DPI setting is currently chosen.

helloUser
  • 41
  • 3
  • The linked question has the code, the answer has a bug fix: https://stackoverflow.com/questions/7727754/how-do-i-enumerate-resolutions-supported-via-twain – Paolo Brandoli Jan 17 '19 at 08:31
  • I believe the code in the link lists the possible DPI settings supported by the scanner but doesn't necessarily give an information as to which setting is currently chosen. – helloUser Jan 17 '19 at 09:34

1 Answers1

0

Okay. I figured it out. It turns out that pTW_ENUMERATION has an attribute named CurrentIndex which stores the index of the chosen DPI. So from the code from How do I enumerate resolutions supported via TWAIN

TW_CAPABILITY twCap;
GetCapability(twCap, ICAP_XRESOLUTION);

TW_UINT32 res = 0;

if (twCap.ConType == TWON_ENUMERATION) {
   pTW_ENUMERATION en = (pTW_ENUMERATION) GlobalLock(twCap.hContainer);

   if (en->ItemType == TWTY_FIX32)  {
      res = ((TW_UINT32*)(en->ItemList))[en->CurrentIndex];

     qDebug()<<res;
   }

}
helloUser
  • 41
  • 3