简体   繁体   English

如何通过TWAIN获取扫描仪的当前DPI设置?

[英]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. 我对Qt并不陌生,现在我们正在开发一个使用TWAIN库控制扫描仪的应用程序。

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. 默认情况下,我们假定扫描仪的DPI设置设置为300。但是,如果偶然,用户在设备设置中手动将扫描仪的DPI设置为600,我们的应用程序必须进行相应的调整。

Is there any way to know the DPI setting of the scanner internally through TWAIN? 是否可以通过TWAIN在内部了解扫描仪的DPI设置? Like know what DPI setting is currently chosen. 就像知道当前选择什么DPI设置一样。

Okay. 好的。 I figured it out. 我想到了。 It turns out that pTW_ENUMERATION has an attribute named CurrentIndex which stores the index of the chosen DPI. 事实证明,pTW_ENUMERATION具有一个名为CurrentIndex的属性,该属性存储所选DPI的索引。 So from the code from How do I enumerate resolutions supported via TWAIN 因此,从“我如何枚举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;
   }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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