Wia代码无法使用柯达scanmate i1120扫描仪

时间:2016-01-22 11:49:16

标签: vb.net wia

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

这个新程序在Windows 10上使用旧的fujitsu fi-4129c2扫描仪正常工作,但我无法使用新的scanmate i1120扫描仪。

我得到的错误在以下一行:

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

我得到的错误是:

Scan Error

我知道代码可以工作,因为我使用的是fujitsu扫描仪,但是我似乎无法弄清楚是什么价值给了我扫描仪上的错误。

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

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

1 个答案:

答案 0 :(得分:0)

原来是扫描仪的WIA_DPS_PAGES设置。

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

(localdb)\v11.0

但在查看Easing Into Using the New AutoStats Feature

之后,这没有用

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

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

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

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