0

I have re-written a program that scans a document and reads a barcode from the document that was written in vb6 and worked on windows xp.

This new program works fine on windows 10 with an old fujitsu fi-4129c2 scanner but I cant get it to work with a new scanmate i1120 scanner.

The error I get is on the following line :

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

and the error I get is :

Scan Error

I know that the code works as I have it working with the fujitsu scanner but I cant seem to figure out what value is giving me the error on the scanmate.

I have just tried it with the following three lines of code only and it still gives me the same error :

Dim CD As New CommonDialog
Dim F As ImageFile = CD.ShowAcquireImage(WiaDeviceType.ScannerDeviceType)
F.SaveFile("C:\Temp\WIA." + F.FileExtension)
Gazza
  • 95
  • 2
  • 9
  • What does the debugger tell you? - Is `ConnectedScanner.Items(1)` a valid object? Does the scanner support that transfer format? – Rowland Shaw Jan 22 '16 at 12:11
  • The ConnectedScanner shows as a valid object. do you know how I would find out if the scanner supports a given transfer format. – Gazza Jan 22 '16 at 12:25
  • Does the OLD program work with the new scanner? If not, it only supports twain, not wia. Usually the specifications will tell you the supported interfaces. – Steve Jan 22 '16 at 15:37
  • just posted an answer – Gazza Jan 22 '16 at 15:40

1 Answers1

0

Turns out it was the WIA_DPS_PAGES setting for the scanner.

I tried changing it using the following code :

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

But this didn`t work so after a look at WIA Scanning via Feeder

I converted the code on this page to vb and used the following 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

And changed the settings using :

SetDeviceProperty(ConnectedScanner, 3096, 1)
SetDeviceProperty(ConnectedScanner, 6146, 2)
SetDeviceProperty(ConnectedScanner, 6147, 300)
SetDeviceProperty(ConnectedScanner, 6148, 300)
SetDeviceProperty(ConnectedScanner, 6154, -50)
SetDeviceProperty(ConnectedScanner, 6155, -50)
Community
  • 1
  • 1
Gazza
  • 95
  • 2
  • 9