⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.frm

📁 使用LEADTOOLS14.5和VB
💻 FRM
📖 第 1 页 / 共 3 页
字号:
            Top             =   945
            Width           =   615
         End
         Begin VB.TextBox txtSelBottom 
            Height          =   285
            Left            =   4920
            TabIndex        =   22
            Top             =   1281
            Width           =   615
         End
         Begin VB.TextBox txtImageBottom 
            Height          =   285
            Left            =   840
            TabIndex        =   16
            Top             =   1281
            Width           =   615
         End
         Begin VB.TextBox txtImageRight 
            Height          =   285
            Left            =   840
            TabIndex        =   15
            Top             =   945
            Width           =   615
         End
         Begin VB.TextBox txtImageLeft 
            Height          =   285
            Left            =   840
            TabIndex        =   13
            Top             =   225
            Width           =   615
         End
         Begin VB.TextBox txtImageTop 
            Height          =   285
            Left            =   840
            TabIndex        =   14
            Top             =   585
            Width           =   615
         End
         Begin VB.TextBox txtWidth 
            Height          =   285
            Left            =   2160
            TabIndex        =   17
            Top             =   228
            Width           =   615
         End
         Begin VB.TextBox txtHeight 
            Height          =   285
            Left            =   2160
            TabIndex        =   18
            Top             =   588
            Width           =   615
         End
         Begin VB.Line Line1 
            X1              =   3072
            X2              =   3072
            Y1              =   72
            Y2              =   1560
         End
         Begin VB.Label Label19 
            AutoSize        =   -1  'True
            Caption         =   "Top"
            Height          =   192
            Left            =   4344
            TabIndex        =   51
            Top             =   636
            Width           =   288
         End
         Begin VB.Label Label18 
            AutoSize        =   -1  'True
            Caption         =   "Left"
            Height          =   192
            Left            =   4344
            TabIndex        =   50
            Top             =   276
            Width           =   276
         End
         Begin VB.Label Label17 
            AutoSize        =   -1  'True
            Caption         =   "Right"
            Height          =   192
            Left            =   4344
            TabIndex        =   49
            Top             =   996
            Width           =   372
         End
         Begin VB.Label Label16 
            AutoSize        =   -1  'True
            Caption         =   "Bottom"
            Height          =   192
            Left            =   4344
            TabIndex        =   48
            Top             =   1332
            Width           =   504
         End
         Begin VB.Label Label14 
            AutoSize        =   -1  'True
            Caption         =   "Bottom"
            Height          =   192
            Left            =   240
            TabIndex        =   40
            Top             =   1327
            Width           =   504
         End
         Begin VB.Label Label13 
            AutoSize        =   -1  'True
            Caption         =   "Right"
            Height          =   192
            Left            =   240
            TabIndex        =   39
            Top             =   991
            Width           =   372
         End
         Begin VB.Label Label9 
            AutoSize        =   -1  'True
            Caption         =   "Left"
            Height          =   192
            Left            =   240
            TabIndex        =   34
            Top             =   271
            Width           =   276
         End
         Begin VB.Label Label10 
            AutoSize        =   -1  'True
            Caption         =   "Top"
            Height          =   192
            Left            =   240
            TabIndex        =   33
            Top             =   631
            Width           =   288
         End
         Begin VB.Label Label11 
            AutoSize        =   -1  'True
            Caption         =   "Width"
            Height          =   192
            Left            =   1560
            TabIndex        =   32
            Top             =   276
            Width           =   420
         End
         Begin VB.Label Label12 
            AutoSize        =   -1  'True
            Caption         =   "Height"
            Height          =   192
            Left            =   1560
            TabIndex        =   31
            Top             =   636
            Width           =   468
         End
      End
   End
   Begin VB.CommandButton LoadLead 
      Caption         =   "Load Existing Image"
      Height          =   372
      Left            =   9000
      TabIndex        =   28
      Top             =   5448
      Width           =   1860
   End
   Begin VB.ComboBox Combo1 
      Height          =   288
      Left            =   120
      TabIndex        =   0
      Top             =   72
      Width           =   3876
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Scanning sample vb6 project by Michael (Max) Larson / Allscripts
'email: max@dark-house.org
'Based partially on samples/examples from LeadTools help files.
'Feel free to use/modify.
'This isn't intended to be an 'end-all' interface...
'it just demonstrates certain aspects of scanning with LeadTools 14.5


Option Explicit
Public WithEvents RasterTwain As LEADRasterTwain
Attribute RasterTwain.VB_VarHelpID = -1
Public TwainCap As New LEADTwainCapability
Public TwnGetCap As New LEADTwainCapability
Public TwnSetCap As New LEADTwainCapability
Public nXferMode As Integer
Public nRet As Integer
Private m_lngScannerCount As Long



Private Sub chkAutoFeed_Click()
    If chkAutoFeed.Value = vbChecked Then
        Combo4.Enabled = True
    End If
End Sub



Private Sub chkDuplexEnabled_Click()
    If chkDuplexEnabled.Value = vbChecked Then
        Combo4.ListIndex = 0
        Combo4.Enabled = False
        cmdDuplexPage2.Enabled = True
        cmdDuplexPage1.Enabled = True
        Label22.Enabled = True
        'if we are scanning duplex,
        'we MUST be able to feed "all" pages, not just one.
    Else
        Label22.Enabled = False
        cmdDuplexPage2.Enabled = False
        cmdDuplexPage1.Enabled = True
        Combo4.Enabled = True
    End If
End Sub



Private Sub cmdDuplexEnabled_Click()
    If (chkDuplexEnabled.Value = 0) Then
        RasterTwain.EnableDuplex = True
        
        chkDuplexEnabled.Value = 1
    Else
        RasterTwain.EnableDuplex = False
        chkDuplexEnabled.Value = 0
    End If
End Sub





Private Sub chkFeederEnabled_Click()
    If chkFeederEnabled.Value = vbChecked Then
        Combo4.Enabled = True
    Else
        Combo4.Enabled = False
    End If
End Sub

Private Sub cmdDuplexPage1_Click()
    LEADRasterView2.Visible = False
End Sub



Private Sub cmdDuplexPage2_Click()
    LEADRasterView2.Visible = True
End Sub



Private Sub cmdSaveImage_Click()
    Dim lngFormat As Long
    Dim lngBPP As Long
    Dim RasterIO As New LEADRasterIO
    Dim strImagePath As String
    Dim strImagePath2 As String
    Dim strTimeStamp As String
    
    On Error GoTo Proc_Error:
    
    strTimeStamp = Now()
    strTimeStamp = Replace(strTimeStamp, "/", "-")
    strTimeStamp = Replace(strTimeStamp, ":", "")
    strTimeStamp = Replace(strTimeStamp, "AM", "")
    strTimeStamp = Replace(strTimeStamp, "PM", "")
    strTimeStamp = Replace(strTimeStamp, " ", "_")

    strImagePath = (txtPath.Text & "_" & strTimeStamp & "." & Combo6.Text)
    strImagePath2 = (txtPath.Text & "_" & strTimeStamp & "2." & Combo6.Text)
    
    'Bits Per Pixel
    Select Case Combo2.Text
        Case 1
            lngBPP = 1
        Case 8
            lngBPP = 8
        Case 24
            lngBPP = 24
    End Select
    
    'File Format
    Select Case Combo6.Text
        Case "BMP"
            lngFormat = FILE_BMP
            RasterIO.Save LEADRasterView1.Raster, strImagePath, lngFormat, lngBPP, 1, SAVE_OVERWRITE
            If chkDuplexEnabled.Value = vbChecked Then
                RasterIO.Save LEADRasterView2.Raster, (strImagePath2), lngFormat, lngBPP, 0, SAVE_REPLACE
            End If
        Case "JPG"
            lngFormat = FILE_JPEG
            RasterIO.Save LEADRasterView1.Raster, strImagePath, lngFormat, lngBPP, 200, SAVE_OVERWRITE
            If chkDuplexEnabled.Value = vbChecked Then
                RasterIO.Save LEADRasterView2.Raster, (strImagePath2), lngFormat, lngBPP, 0, SAVE_REPLACE
            End If
        Case "GIF"
            lngFormat = FILE_GIF
            RasterIO.SaveInterlaced = True
            RasterIO.Save LEADRasterView1.Raster, strImagePath, lngFormat, lngBPP, 1, SAVE_OVERWRITE
            'if we scanned two sides, save them both as a multipage tif
            If chkDuplexEnabled.Value = vbChecked Then
                RasterIO.Save LEADRasterView2.Raster, (strImagePath2), lngFormat, lngBPP, 0, SAVE_REPLACE
            End If
        
        Case "TIF"
            lngFormat = FILE_TIF
            RasterIO.SavePage = 1
            RasterIO.Save LEADRasterView1.Raster, strImagePath, lngFormat, lngBPP, 0, SAVE_REPLACE
            'if we scanned two sides, save them both as a multipage tif
            If chkDuplexEnabled.Value = vbChecked Then
                RasterIO.SavePage = 2
                RasterIO.Save LEADRasterView2.Raster, (strImagePath), lngFormat, lngBPP, 0, SAVE_REPLACE
            End If
    End Select

    
'Reload the image we just saved.
    LEADRasterView1.PaintWhileLoad = True
    RasterIO.ProgressivePasses = PROGRESSIVEPASSES_WHEN_MEANINGFUL
    RasterIO.Load LEADRasterView1.Raster, strImagePath, 0, 0, 1
    LEADRasterView1.ForceRepaint


    MsgBox "Image saved to: " & strImagePath & IIf(chkDuplexEnabled.Value = vbChecked, " / " & strImagePath2, "")

Proc_Error:
    Exit Sub

End Sub


Private Sub cmdSelect_Click()
  'display select source dialog and tells us if there was an error with selection

End Sub


'''Private Sub cmdTestTwain_Click()
'''   Set RasterTwain = New LEADRasterTwain
'''   Dim CapVal As New LEADRasterVariant
'''   RasterTwain.InitSession hWnd
'''
'''   TwainCap.CapInfo.Capability = L_ICAP_XFERMECH
'''   TwainCap.CapInfo.ConType = L_TWON_ONEVALUE
'''   TwainCap.CapOneValue.OneValItemType = L_TWTY_UINT16
'''   CapVal.Type = VALUE_USHORT
'''   CapVal.LongValue = L_TWSX_NATIVE
'''
'''   TwainCap.CapOneValue.OneValCapValue = CapVal
'''
'''   RasterTwain.SetCapability2 TwainCap, L_LTWAIN_CAPABILITY_SET
'''
'''   RasterTwain.Acquire L_LTWAIN_SHOW_USER_INTERFACE
'''   RasterTwain.EndSession
'''End Sub


Private Sub Combo4_Change()
    If Combo4.ListIndex = 0 Then txtXferPages.Text = -1
    If Combo4.ListIndex = 1 Then txtXferPages.Text = 1
End Sub


Private Sub Combo4_Click()
    If Combo4.ListIndex = 0 Then txtXferPages.Text = -1
    If Combo4.ListIndex = 1 Then txtXferPages.Text = 1
End Sub


Private Sub cmdAcquire_Click()
'TWAIN ACQUIRE TEST ROUTINE

   
    Dim blnFeederEnabled As Boolean
    Dim blnDuplexEnabled As Boolean
    Dim blnAutoFeedEnabled As Boolean
    Dim nUnit As Integer
    Dim RasVar As New LEADRasterVariant
   
    'if for some reason the dropdown did not load and initialize with scanner,
    'call the default scanner dialog
    If Combo1.Text = "" Then
        Dim nRet As Integer
        nRet = RasterTwain.SelectSource
        If (nRet <> 0) Then
            MsgBox "Error Selecting Source", vbExclamation
        End If
    End If
   
    nUnit = RasterTwain.ImageUnit
    
    'set the Bits Per Pixel and the UNIT
    RasterTwain.ImageUnit = L_TWUN_INCHES
    If nUnit <> L_TWUN_INCHES Then RasterTwain.ImageUnit = L_TWUN_INCHES
    RasterTwain.ImageBitsPerPixel = CLng(Combo2.Text)
    
    'Set Duplex Flag
    blnDuplexEnabled = chkDuplexEnabled.Value
    RasterTwain.EnableDuplex = blnDuplexEnabled
    
    'Set Feeder Flag
    RasterTwain.MaxXferCount = CLng(txtXferPages.Text)
    blnAutoFeedEnabled = chkAutoFeed.Value
    RasterTwain.EnableAutoFeed = blnAutoFeedEnabled
    'we should also test this: chkFeederEnabled.Value
    
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -