110,556
社区成员
发帖
与我相关
我的任务
分享
从数据区块读取base64编码的图片数据
codekey = ape:loadTable("验证码样本");
imgBinKey = {}; --这是一个图像数组,用来储存还原后的验证码样本的图片数据
--必须进行一个转换,因为codekey里面只是base64编码的普通字符串,而imgBinKey 将是真正的图片对象(二进制数据)
--还原到图片对象
toImage = function(k,v)
local img9 = image.new();
img9:setBytes( string.decode( v ,"") ,"*.jpg");
imgBinKey[k] = img9;
end;
table.foreach(codekey,toImage);
--下载验证码图片
imgD = image.new();
if (imgD:getURL("/Article/UploadFiles/200508/20050831203415539.jpg") ~= true) then
win.messageBox("下载图像失败","")
image.del(imgD)
do return false end;
end;
image.corp(imgD, 9 ,0 , 41 , 20 );
--使用split函数分割图片
img2,img3,img4,img5 = imgD:split(1,4);
function test(imgX)
limit = 1;
chr = "";
win.messagePrint("正在检测图片,请稍候....")
testimg = function(k,v)
local n = imgX:testX(imgBinKey[k]);
if(nlimit = n;
chr = k.."";
end;
end;
table.foreach(imgBinKey,testimg);
return chr;
end;
win.messageBox("验证码".. test(img2)..test(img3)..test(img4)..test(img5),"")