Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nImageID As Integer
Dim ms As Array
If twain1.TwainOpenDefaultSource() Then
If twain1.TwainGetState() = "4" Then
InitScanConfig()
twain1.TwainSetImageLayout(0.1, 0.3, 2, 5.3)
twain1.TwainSetCurrentResolution(150)
twain1.TwainSetCurrentPixelType(Gdtwain.TwainPixelType.TWPT_RGB) 'RGB
twain1.TwainSetCurrentBitDepth(4) ' 24 bpp
nImageID = twain1.TwainAcquireToImageID(Me.Handle.ToInt32)
If nImageID <> 0 Then
Call DisplayNativeImage()
Call twain1.SaveAsByteArray(ms, 100000, "jpg")
Call twain1.CloseImage(nImageID)
End If
Call twain1.TwainCloseSourceManager(Me.Handle.ToInt32)
'MsgBox("Done !")
Else
MsgBox("can't open default source, twain state is: " & Trim(Str(twain1.TwainGetState)))
End If
End If
Button3.Enabled = True
End Sub