找回密码
 加入
搜索
查看: 10566|回复: 10

[效率算法] 二维码的解码

  [复制链接]
发表于 2013-8-6 13:31:41 | 显示全部楼层 |阅读模式
本帖最后由 楼上风云 于 2013-8-7 12:49 编辑

一、任务目标:对二维码图片进行解码
二、目标图片:
三、编码内容:——————————————————————
          已解码数据 1 [模型版本: 8, 等级: M(15%)]
              ——————————————————————
          免责声明

          注意:本文只可用于科学/研究的目的。
          本文作者不对将在此展示内容的非法用途负有任何责任。
          如果你同意本声明,才被允许阅读这篇文章。

          符号位置:(16, 16)-(212, 16)-(212, 212)-(16, 212)
四、上传附件:
    文件列表:MainVB.txt             VB编码的示例调用程序,有乱码
                     MainVbAu3.AU3     尝试的AU3调用示例,有BUG,尚未完全读取成功
                    QrDcd.dll                 关键DLL,解码必须
                    QrDcd.txt                解码DLL函数表,有乱码
                    QrDcdDLL.AU3        尝试转换的DLL函数UDF,部分函数未能实现功能。增加了注册子函数。
                    QRCHS.PNG            目标二维码图片
五、问题求解:
             1、源程序中,QrDcdDLL.AU3中的GetDecodeVersion子函数未能实现功能,从而解码未能成功。
六、特别鸣谢:LPXX大侠帮助,基本解决日文乱码。
;本次更新部分代码,2013-08-07免费代码包:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-8-6 13:33:13 | 显示全部楼层
是問問題  還是發表心得??
发表于 2013-8-6 13:36:29 | 显示全部楼层
提问还要付钱?
 楼主| 发表于 2013-8-6 13:42:37 | 显示全部楼层
本帖最后由 楼上风云 于 2013-8-6 21:01 编辑

回复 3# lpxx

发贴时搞错了,无意收费,结果...
尝试重新编辑以取消收费时,发帖失败。
此处免费,算是修正。
附上免费附件

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2013-8-6 13:44:30 | 显示全部楼层
回复 2# kk_lee69

兄弟,此贴当然是提问。问题尚未解决,岂是何感之有?
发表于 2013-8-6 14:01:46 | 显示全部楼层
本帖最后由 lpxx 于 2013-8-6 14:04 编辑

看了一下,是日文的,上传txt格式谷歌翻译一下。

http://translate.google.cn/?sourceid=cnhp#ja/zh-CN/

翻译不准确的,剩下的就你自己完善了。

测试了一下,翻译的不太准确。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-8-6 14:22:28 | 显示全部楼层
附上帮你翻译的MainVB.txt
Friend 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
 楼主| 发表于 2013-8-6 15:29:49 | 显示全部楼层
回复 6# lpxx

大侠,翻译的东东有过修改吧?看起来很不错了。剩下的,我继续接力
发表于 2020-9-9 00:17:25 | 显示全部楼层
不能运行。
是不是哪里出问题了。求解。
发表于 2020-9-9 00:21:50 | 显示全部楼层
发到提问区,是有问题需要解决?
发表于 2020-9-9 13:44:01 | 显示全部楼层
haijie1223 发表于 2020-9-9 00:21
发到提问区,是有问题需要解决?

楼上的挖坟,你也跟着递铲子
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 01:35 , Processed in 0.081843 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表