附上帮你翻译的MainVB.txtFriend Class formMain
Inherits System.Windows.Forms.Form
'解码范围规范
Public blnEnableSetRect As Boolean = False
Public intRectLeft As Integer = 0
Public intRectTop As Integer = 0
Public intRectRight As Integer = 0
Public intRectBottom As Integer = 0
'解码条件设置
Public intSymbolCount As Integer = 0
Public intEffectLevel As Integer = 3
Public byBorder As Byte = 0
Public byModuleSize As Byte = 1
Dim intFilterIndex As Short = 1 '图片文件
Private Sub formMain_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
'文本框适合客户端
textDecodeResult.Width = ClientRectangle.Width
textDecodeResult.Height = ClientRectangle.Height - MenuStrip1.Height
End Sub
Private Sub textDecodeResult_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles textDecodeResult.DragEnter
'支持拖放文件
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub textDecodeResult_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles textDecodeResult.DragDrop
'文件拖放处理
DecodeFile(e.Data.GetData(DataFormats.FileDrop)(0))
End Sub
Private Sub menuFileOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuFileOpen.Click
'处理[打开] - [文件]
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Filter = "图片文件 (*.bmp;*.jpg;*.jpeg;*.gif;*.tif;*.tiff;*.png)|*.bmp;*.jpg;*.jpeg;*.gif;*.tif;*.tiff;*.png|" & _
"位图文件 (*.bmp)|*.bmp|" & _
"JPEG格式 (*.jpg;*.jpeg)|*.jpg;*.jpeg|" & _
"GIF格式 (*.gif)|*.gif|" & _
"TIFF格式 (*.tif;*.tiff)|*.tif;*.tiff|" & _
"PNG格式 (*.png)|*.png|" & _
"所有文件 (*.*)|*.*"
openFileDialog1.FilterIndex = intFilterIndex
openFileDialog1.RestoreDirectory = True
'通用对话框,选择文件
If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
intFilterIndex = openFileDialog1.FilterIndex
DecodeFile(openFileDialog1.FileName)
End If
End Sub
Private Sub menuAppExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuAppExit.Click
'程序结束
Close()
End Sub
Private Sub menuSetDecodeRect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuSetDecodeRect.Click
'对话框显示解码范围
formSetRect.ShowDialog() '模式显示
End Sub
Private Sub menuSetDecodeProperty_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuSetDecodeProperty.Click
'解码条件设置对话框
formSetProperty.ShowDialog() '模式显示
End Sub
Private Sub DecodeFile(ByVal strFilePath As String)
'解码目标图像文件
'沙漏光标
Cursor = System.Windows.Forms.Cursors.WaitCursor
'DLL函数的解码
Dim intResult As Integer
If blnEnableSetRect Then
'有不等规范
intResult = DecodePictureFileRect(strFilePath, intRectLeft, intRectTop, intRectRight, intRectBottom)
Else
'没有范围规范
intResult = DecodePictureFile(strFilePath)
End If
'光标恢复
Cursor = System.Windows.Forms.Cursors.Default
Dim strResult As String = ""
If intResult >= 1 Then
'解码成功完成
Dim i As Integer
For i = 0 To intResult - 1
strResult = strResult & "───────────────────────────" & vbCrLf
'格式信息
strResult = strResult & "解码数据 " & Format(i + 1)
strResult = strResult & "编号:" & Format(GetDecodeVersion(i))
strResult = strResult & ", 水平:"
Select Case GetDecodeLevel(i)
Case 0
strResult = strResult & "L(7%)"
Case 1
strResult = strResult & "M(15%)"
Case 2
strResult = strResult & "Q(25%)"
Case 3
strResult = strResult & "H(30%)"
End Select
'综合信息
Dim intCount As Integer
Dim intSeqNo As Integer
Dim byCheckDigit As Byte
intCount = GetConcatenationInfo(i, intSeqNo, byCheckDigit)
If intCount > 0 Then
strResult = strResult & ", 连接方式:" & Format(intSeqNo + 1) & "/" & Format(intCount)
strResult = strResult & "(CD:" & Hex(byCheckDigit \ &H10S) & Hex(byCheckDigit Mod &H10S) & "H)"
End If
strResult = strResult & "]" & vbCrLf
strResult = strResult & "───────────────────────────" & vbCrLf
''符号数据
strResult = strResult & GetDecodeDataString(i) & vbCrLf & vbCrLf
'位置信息
Dim intPosition(7) As Integer
intResult = GetSymbolePosition(i, intPosition(0))
strResult = strResult & "符号的位置是" & _
"(" & Format(intPosition(0)) & ", " & Format(intPosition(1)) & ")-" & _
"(" & Format(intPosition(2)) & ", " & Format(intPosition(3)) & ")-" & _
"(" & Format(intPosition(4)) & ", " & Format(intPosition(5)) & ")-" & _
"(" & Format(intPosition(6)) & ", " & Format(intPosition(7)) & ")"
strResult = strResult & vbCrLf & vbCrLf
Next i
'开放的解码结果存储器
FreeAllocateMemory()
Else
'解码错误
Select Case intResult
Case QRD_ERROR_SYMBLE_NOT_FOUND
strResult = "QR码符号没有被发现"
Case QRD_ERROR_FILE_NOT_FOUND
strResult = "找不到文件"
Case QRD_ERROR_READ_FAULT
strResult = "读取文件发生了错误"
Case QRD_ERROR_BAD_FORMAT
strResult = "不能被读取的文件类型"
Case QRD_ERROR_SHARING_VIOLATION
strResult = "共享冲突,无法读取文件"
Case QRD_ERROR_NOT_ENOUGH_MEMORY
strResult = "内存不足"
End Select
End If
textDecodeResult.Text = strResult
End Sub
End Class
|