【问题标题】:Wia code won`t work with kodak scanmate i1120 scannerWia 代码不适用于 kodak scanmate i1120 扫描仪
【发布时间】:2016-01-22 11:49:16
【问题描述】:

我重新编写了一个程序,它可以扫描文档并从用 vb6 编写并在 windows xp 上工作的文档中读取条形码。

这个新程序在带有旧 fujitsu fi-4129c2 扫描仪的 Windows 10 上运行良好,但我无法让它与新的 scanmate i1120 扫描仪一起工作。

我得到的错误在以下行:

MyImage = DirectCast(ConnectedScanner.Items(1).Transfer(WIA.FormatID.wiaFormatBMP), WIA.ImageFile)

我得到的错误是:

我知道代码在使用 fujitsu 扫描仪时可以正常工作,但我似乎无法弄清楚是什么值导致我在 scanmate 上出现错误。

我刚刚尝试了以下三行代码,它仍然给我同样的错误:

Dim CD As New CommonDialog
Dim F As ImageFile = CD.ShowAcquireImage(WiaDeviceType.ScannerDeviceType)
F.SaveFile("C:\Temp\WIA." + F.FileExtension)

【问题讨论】:

  • 调试器告诉你什么? - ConnectedScanner.Items(1) 是一个有效的对象吗?扫描仪是否支持该传输格式?
  • ConnectedScanner 显示为有效对象。你知道我怎么知道扫描仪是否支持给定的传输格式。
  • 旧程序是否适用于新扫描仪?如果没有,它只支持twain,不支持wia。通常规格会告诉您支持的接口。
  • 刚刚发布了答案

标签: vb.net wia


【解决方案1】:

原来是扫描仪的 WIA_DPS_PAGES 设置。

我尝试使用以下代码更改它:

With ConnectedScanner.Items(1)
        .Properties("3096").Value = 1
        .Properties("6146").Value = 2 
        .Properties("6147").Value = 300 'dots per inch/horizontal
        .Properties("6148").Value = 300 'dots per inch/vertical
        .Properties("6154").Value = -50 'brightness
        .Properties("6155").Value = -50 ' contrast
    End With

但这并没有奏效,所以看了WIA Scanning via Feeder

我将此页面上的代码转换为vb并使用以下Sub:

Public Sub SetDeviceProperty(device As Device, propertyId As Integer, value As Object)
    Dim [property] As [Property] = FindProperty(device.Properties, propertyId)
    If [property] IsNot Nothing Then
        [property].let_Value(value)
    End If
End Sub

并使用以下方法更改设置:

SetDeviceProperty(ConnectedScanner, 3096, 1)
SetDeviceProperty(ConnectedScanner, 6146, 2)
SetDeviceProperty(ConnectedScanner, 6147, 300)
SetDeviceProperty(ConnectedScanner, 6148, 300)
SetDeviceProperty(ConnectedScanner, 6154, -50)
SetDeviceProperty(ConnectedScanner, 6155, -50)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-08
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-05
    • 2012-05-18
    • 1970-01-01
    相关资源
    最近更新 更多