找回密码
 加入
搜索
查看: 2581|回复: 4

[转贴] 关于Base64图片转换窗口展示

[复制链接]
发表于 2019-6-5 12:30:00 | 显示全部楼层 |阅读模式
感谢论坛中朋友们的帖子,这边我借用了@guoyaqiu源代码进行修改展示。Local $CodeStream ="data:image/jpeg;base64, /9j/4AAQSkZJRgABAQAAAQABAAD//gA+Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBkZWZhdWx0IHF1YWxpdHkK/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAIgCZAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8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gJGlt5h5sEpOd6Hpz3P+e9ZFbt94l/tHS4rC4022EcC4haMuDHxjjJOfoawqulz8tp7kVeXmvHYKtaZcfZdUtZ848uVWP0zzVWiraurEJ2dzqdZEUHiG/e6i81YWEsYzjJIXg+oGc/h71zDuXkZ2YsWJJLHJP1rRn1KXVdV+0XG1dyFMDoBtxWZWdGDiknvZF1JJu6CiiitTMqb2/vH86N7f3j+dFFIoN7f3j+dG9v7x/OiigA3t/eP50b2/vH86KKADe394/nRvb+8fzoooAUyOSSXYk980m9v7x/OiikAb2/vH86N7f3j+dFFMA3t/eP50b2/vH86KKADe394/nRvb+8fzoooAN7f3j+dG9v7x/OiigByM24fMfzqzRRTQmf/9k="
$CodeStream = StringReplace($CodeStream, "data:image/jpeg;base64, ", "")
        _CreateWaybillImage($CodeStream)
        ConsoleWrite("$CodeStream :" & $CodeStream & @CRLF)
        Local $codeGUI = GUICreate("验证码", 240, 200, -1, -1, $WS_SIZEBOX + $WS_SYSMENU)
        Local $CodePic = @ScriptDir & "\code.jpg"
        Local $Pic = GUICtrlCreatePic($CodePic, 45, 15, 150, 60)
        Local $CodeLabel = GUICtrlCreateLabel("验证码:", 15, 95, 70, 30)
        GUICtrlSetFont($CodeLabel, 12, "", "", "")
        Local $InputCode = GUICtrlCreateInput("", 85, 90, 130, 25)
        GUICtrlSetFont($InputCode, 12, "", "", "")
        Local $CodeBtn = GUICtrlCreateButton("确定", 85, 130, 70, 30)
        Local $CodeValue = ""
        GUISetState(@SW_SHOW, $codeGUI)
        WinSetOnTop($codeGUI, "", $WINDOWS_ONTOP) ;窗口前置
        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                GUIDelete($codeGUI)
                                ExitLoop
                        Case $CodeBtn
                                GUIDelete($codeGUI)
                                ExitLoop
                        Case Else
                                $CodeValue = GUICtrlRead($InputCode)
                EndSwitch
        WEnd
        GUIDelete($codeGUI)
        ConsoleWriteLine("输入的验证码:" & $CodeValue & @CRLF)

#Region 将base64转换成图片
Func _CreateWaybillImage($Base64)
        Local $temp
        $objXMLDoc = ObjCreate("Msxml2.DOMDocument")
        $objDocElem = $objXMLDoc.CreateElement("base64")
        $objDocElem.dataType = "bin.base64"
        $objDocElem.nodeTypedValue = $Base64

        $temp = FileOpen("code.jpg", $FO_UTF8 + $FO_BINARY + $FO_OVERWRITE)
        FileWrite($temp, $objDocElem.nodeTypedValue)
        FileFlush($temp)
        FileClose($temp)
        $objXMLDoc = Null
EndFunc   ;==>_CreateWaybillImage
#EndRegion 将base64转换成图片


本帖子中包含更多资源

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

×
发表于 2019-6-7 21:03:11 | 显示全部楼层
你为什么不用一下论坛的代码模块呢?晕死
 楼主| 发表于 2019-6-10 08:46:43 | 显示全部楼层
cfanpc 发表于 2019-6-7 21:03
你为什么不用一下论坛的代码模块呢?晕死

没有明白你什么意思?
发表于 2019-7-8 22:20:31 | 显示全部楼层
qxguoxing 发表于 2019-6-10 08:46
没有明白你什么意思?

论坛有个代码模块,你代码写里面,更好看。
 楼主| 发表于 2019-10-15 14:06:04 | 显示全部楼层
cfanpc 发表于 2019-7-8 22:20
论坛有个代码模块,你代码写里面,更好看。

好的,下次发代码时用这个。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-22 14:12 , Processed in 0.090296 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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