找回密码
 加入
搜索
查看: 1768|回复: 2

[图形处理] 验证码这块有没有二维array 转换为 图片的方法呀?

[复制链接]
发表于 2012-3-7 01:11:00 | 显示全部楼层 |阅读模式
好像在哪里看到,么找到,求助
多谢啦哈哈
发表于 2012-3-7 01:25:33 | 显示全部楼层
不懂,帮顶
发表于 2012-3-8 14:24:24 | 显示全部楼层
在这有:http://www.autoitx.com/thread-20741-1-1.html
Func _myWriteArrayToBmpFile($func_array, $s_newFile)
        If UBound($func_array)=0 Or UBound($func_array,3)>0 Then Return ""
        ;If UBound($func_array,2)>0 Then _myArray2dTo1d($func_array)
        If StringLower(StringRight($s_newFile,4))<>".bmp" Then $s_newFile &=".Bmp";只支持Bmp
        FileDelete($s_newFile)
        If FileExists($s_newFile) Then Return "";不可写'
        
        If UBound($func_array,2)=0 Then;一维数组
                Local $i_height = UBound($func_array) ;高
                Local $i_width = StringLen($func_array[0])/6 ;宽
        Else;二维数组
                Local $i_height = UBound($func_array,2) ;高
                Local $i_width = UBound($func_array);宽
        EndIf
        Local $head=DllStructcreate("ubyte[54]")
        ;lets create a bitmapfile with the given data
        Local $Bmpheader = DllStructCreate("align 1;char BM[2];uint Size;uint res;uint Offset;uint BMHI;uint Width;uint Height;short Planes;"& _
        "short BPP;uint BIcomp;int SizeImg;uint reshor;uint resver;uint col;uint colused", dllstructgetptr($head))
        ;fill struct(bitmapheader) with data
        Local $iLen=$i_width*$i_height*3
        DllStructSetData($bmpheader,"BM","BM")
        DllStructSetData($bmpheader,"Size",54+$iLen)
        DllStructSetData($bmpheader,"Offset",54)
        DllStructSetData($bmpheader,"BMHI",40)
        DllStructSetData($bmpheader,"Width",$i_width)
        DllStructSetData($bmpheader,"Height",-$i_height)
        DllStructSetData($bmpheader,"Planes",1)
        DllStructSetData($bmpheader,"BPP",24)
        DllStructSetData($bmpheader,"BIcomp",0)

        Local $header = dllstructgetdata($head,1) ;headerdata

        Local $filehandle = FileOpen($s_newFile, 18) ;write file
        FileWrite($filehandle,$header)
        Local $s_bott="",$i
        For $i = 1 To Mod($i_width,4)
                $s_bott &= "0"
        Next
        ;ConsoleWrite($s_bott&@CRLF)
        Local $y
        If UBound($func_array,2)=0 Then
                For $y=0 To $i_height-1
                        FileWrite($filehandle,"0x"&$func_array[$y])
                        FileWrite($filehandle,$s_bott)
                Next
        Else
                Local $x
                For $y=0 To $i_height-1
                        For $x=0 To $i_width-1
                                FileWrite($filehandle,"0x"&$func_array[$x][$y])
                        Next
                        FileWrite($filehandle,$s_bott)
                Next
        EndIf
        FileClose($filehandle)
        
        If FileExists($s_newFile) Then
                Return $s_newFile
        Else
                Return ""
        EndIf
EndFunc

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-7 08:39 , Processed in 0.085116 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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