QQ截图20151130143437.jpg (979 Bytes, 下载次数: 1770)
下载附件 保存到相册
9 年前 上传
package com.xuanyao.server.imgcode; import java.awt.image.BufferedImage; import java.util.HashMap; import java.util.Map; public class AsiaImageCodeParse { private int useXstart = 6; private int useYstart = 5; private int useXover = 15; private int useYover = 39; private StringBuffer codebuffer = new StringBuffer(); private StringBuffer one = new StringBuffer(); private StringBuffer two = new StringBuffer(); private StringBuffer three = new StringBuffer(); private StringBuffer four = new StringBuffer(); private final String er = "00111100011001101100001100000011000001100000110000011000001100000110000011111111";//2 private final String san="01111100110001100000001100000110000111000000011000000011000000111100011001111100";//3 private final String si="00000110000011100001111000110110011001101100011011111111000001100000011000000110";//4 private final String wu="11111110110000001100000011011100111001100000001100000011110000110110011000111100";//5 private final String liu="00111100011001101100001011000000110111001110011011000011110000110110011000111100";//6 private final String qi="11111111000000110000001100000110000011000001100000110000011000001100000011000000";//7 private final String ba="00111100011001101100001101100110001111000110011011000011110000110110011000111100";//8 private final String jiu="00111100011001101100001111000011011001110011101100000011010000110110011000111100";//9 private final Map<String, Integer> codemap = new HashMap<String, Integer>(); { codemap.put(er, 2); codemap.put(san, 3); codemap.put(si, 4); codemap.put(wu, 5); codemap.put(liu, 6); codemap.put(qi, 7); codemap.put(ba, 8); codemap.put(jiu, 9); } //将图片解析成1,0编码的字符串 public String PaseByte(BufferedImage img){ for(int i=0;i<20;i++){ for(int j=0;j<50;j++){ //16777216 //2565928 if((j>=useYstart&&j<=useYover)&&(i>=useXstart&&i<=useXover)) if(img.getRGB(j, i)==-2565928){ codebuffer.append("0"); }else{ codebuffer.append("1"); } } codebuffer.append(","); } return SplitByte(codebuffer); } //将字符串拆分为4个单独的1,0编码 public String SplitByte(StringBuffer codebuffer){ for(String s:codebuffer.toString().split(",")){ if(s.length()==35){ one.append(s.substring(0, 8)); two.append(s.substring(9, 17)); three.append(s.substring(18, 26)); four.append(s.substring(27, 35)); } } return GetCode(); } public String GetCode(){ return codemap.get(one.toString())+""+ codemap.get(two.toString())+""+ codemap.get(three.toString())+""+ codemap.get(four.toString()); } }
来源:即时通讯网 - 即时通讯开发者社区!
轻量级开源移动端即时通讯框架。
快速入门 / 性能 / 指南 / 提问
轻量级Web端即时通讯框架。
详细介绍 / 精编源码 / 手册教程
移动端实时音视频框架。
详细介绍 / 性能测试 / 安装体验
基于MobileIMSDK的移动IM系统。
详细介绍 / 产品截图 / 安装体验
一套产品级Web端IM系统。
详细介绍 / 产品截图 / 演示视频
引用此评论
引用:JackJiang 发表于 2015-11-30 15:23 这方面的资料不多,支持原创。
精华主题数超过100个。
连续任职达2年以上的合格正式版主
为论区做出突出贡献的开发者、版主等。
Copyright © 2014-2024 即时通讯网 - 即时通讯开发者社区 / 版本 V4.4
苏州网际时代信息科技有限公司 (苏ICP备16005070号-1)
Processed in 0.125000 second(s), 39 queries , Gzip On.