简体   繁体   中英

How to get current DPI setting of the scanner through TWAIN?

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.

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;
   }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM