this is my code
Code: Select all
Private Sub FrmMantenimientoDTU_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.InfoTab.SelectedTabPageIndex = 0
Axtwain1.SetLicenseNumber("XXXXXX")
End Sub
Private Sub ScanImage(ByVal ScanMode As String)
Dim nImageID As Integer
Dim ImageName As String = ""
Try
If Axtwain1.TwainOpenDefaultSource() Then
'Configura el Escaner
Axtwain1.TwainSetHideUI(True)
Axtwain1.TwainSetIndicators(True)
Axtwain1.TwainSetAutoBrightness(True)
Axtwain1.TwainSetCurrentContrast(0)
Axtwain1.TwainEnableDuplex(False)
'Configura la imagen
Axtwain1.TwainSetCurrentResolution(150)
Axtwain1.TwainSetCurrentPixelType(Gdtwain.TwainPixelType.TWPT_BW) 'RGB
Axtwain1.TwainSetCurrentBitDepth(8) ' 24 bpp
nImageID = Axtwain1.TwainAcquireToImageID(Me.Handle.ToInt32)
If nImageID <> 0 Then
If System.IO.Directory.Exists(Funciones.App_Path & "Documents\DUT" & Me.TxtCorrelativo.Text) = False Then
System.IO.Directory.CreateDirectory(Funciones.App_Path & "Documents\DUT" & Me.TxtCorrelativo.Text)
End If
If ScanMode = "Agregar" Then
If Me.TreeDocs.FocusedNode.GetValue("ParentID").ToString.Trim = "-1" Then
ImageName = Replace(Funciones.App_Path & "\Documents\DUT" & Me.TxtCorrelativo.Text & "\" & Me.TreeDocs.FocusedNode.GetValue("CodigoDocumento").ToString.Trim & (Me.TreeDocs.FocusedNode.Nodes.Count + 1).ToString & ".gif", "\\", "\")
Else
ImageName = Replace(Funciones.App_Path & "\Documents\DUT" & Me.TxtCorrelativo.Text & "\" & Me.TreeDocs.FocusedNode.ParentNode.GetValue("CodigoDocumento").ToString.Trim & (Me.TreeDocs.FocusedNode.ParentNode.Nodes.Count + 1).ToString & ".gif", "\\", "\")
End If
Else
ImageName = Me.TreeDocs.FocusedNode.GetValue("Path").ToString.Trim
Me.Imagen.Image.Dispose()
Me.Imagen.Image = Nothing
End If
Call Axtwain1.SaveAsGif(ImageName)
Call Axtwain1.CloseImage(nImageID)
Me.Imagen.ImageLocation = ImageName
Me.Imagen.Show()
AgregarDoc(ImageName, ScanMode)
Me.TreeDocs.FocusedNode.SetValue("Path", ImageName)
End If
Axtwain1.TwainCloseSourceManager(Me.Handle.ToInt32)
End If
Catch ex As Exception
FrmMessageBox.Mostrar(ex.Message, TituloError)
End Try
End Sub