- 浏览: 131773 次
- 性别:
- 来自: 大连
文章分类
最新评论
-
datawarehouse:
datawarehouse 写道ngix 淘宝是基于这个开发了 ...
解密淘宝网的开源架构 -
datawarehouse:
ngix 淘宝是基于这个开发了一个自己的webserver吧。 ...
解密淘宝网的开源架构 -
eyelock:
我运行报错,,楼主能解答一下G,对swing不熟。
raphi ...
假期没事,写了个90行的俄罗斯方块,Java实现,史上最小巧 -
lostsky_11:
楼主写出例子了么?物理碰撞部分可能跟你说的差不多渲染部分可以搜 ...
Where is my water 游戏算法 -
xouou_53320:
都是牛人
假期没事,写了个90行的俄罗斯方块,Java实现,史上最小巧
java 代码
- 做了个刷投票的程序 识别随即码图片的地方用到了BMP图片识别 需要识别出BMP图片里的数字
- 网站的BMP图片格式比较规则 20 * 45 的大小 每个数字大小是 10 * 8 左侧空 5 像素 右侧 5 像素
- 研究BMP图片格式发现 BMP主要包括 3 部分 头 颜色表 图像数据区
- 图像结构如下 类似C++里的结构体
- public class BMPHeader {
- public byte [] bm = new byte [ 2 ]; // 2位 BM
- public byte [] size = new byte [ 4 ]; // 4位 2038 (f6 07)
- public byte [] save = new byte [ 4 ]; // 4位 00
- public byte [] dataPos = new byte [ 4 ]; // 4位 图像数据区位置
- // (3604)文件头信息块大小,图像描述信息块的大小,图像颜色表的大小,保留(为01)
- public byte [] desSize = new byte [ 4 ]; // 4位图像描述信息块大小28h
- public byte [] width = new byte [ 4 ]; // 4位 宽度
- public byte [] hight = new byte [ 4 ]; // 4位 高度
- public byte [] plane = new byte [ 2 ]; // 2位 plane为0100
- public byte [] bytes = new byte [ 2 ]; // 2位 图像的位数 0800
- public byte [] zip = new byte [ 4 ]; // 4位 压缩方式00不压缩
- public byte [] picSize = new byte [ 4 ]; // 4位 c0 03 = 960 图像区数据的大小
- public byte [] shuiPing = new byte [ 4 ]; // 4位 水平每米有多少像素
- public byte [] cuiZhi = new byte [ 4 ]; // 4位 垂直每米有多少像素
- public byte [] colorNum = new byte [ 4 ]; // 4位 此图像所用的颜色数
- // 图像数据从436-7f5
- public byte [] colorTab = new byte [ 1028 ];
- public byte [] bmpData = new byte [ 960 ];
- }
- 颜色表ColorTab应该为 1024 长 不知道为什么会是 1028 没算明白这里
- 图像数据区是 960 位 每一位都是一个颜色点 保存颜色表中的索引数据 16 进制 3 行表示图像中的一行
- 从下往上排列 45 = 16 * 3 - 3 有 3 位补零 因为bmp要保证每行数据点要为 4 的整数倍
- 得到数据内容就可以根据行列坐标定位每一点的颜色 从而判断出图像中的数字
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- public class BMPTest {
- private byte [][] parse960ToLine( byte [] bmpData) {
- int lineSize = 48 ;
- int columnIndex = 0 ;
- int rowIndex = 0 ;
- byte [][] bmp = new byte [ 20 ][ 48 ];
- for ( int i = 0 ; i < bmpData.length; i++) {
- bmp[rowIndex][columnIndex] = bmpData[i];
- columnIndex++;
- if (columnIndex == 48 ) {
- rowIndex++;
- columnIndex = 0 ;
- }
- }
- return bmp;
- }
- private short parse1Num( byte [][] theByte) {
- if (theByte[ 0 ][ 0 ] == 0 && theByte[ 0 ][ 1 ] == 0 && theByte[ 0 ][ 2 ] == 0
- && theByte[ 0 ][ 3 ] == 0 && theByte[ 0 ][ 4 ] == 0
- && theByte[ 0 ][ 5 ] == 0 && theByte[ 0 ][ 6 ] == 0
- && theByte[ 0 ][ 7 ] == 0 && theByte[ 7 ][ 0 ] == 0
- && theByte[ 7 ][ 1 ] == 0 && theByte[ 1 ][ 1 ] == 0
- && theByte[ 1 ][ 2 ] == 0 && theByte[ 2 ][ 2 ] == 0
- && theByte[ 2 ][ 3 ] == 0 && theByte[ 3 ][ 3 ] == 0
- && theByte[ 3 ][ 4 ] == 0 && theByte[ 4 ][ 4 ] == 0 ) {
- return 2 ;
- } else if (theByte[ 0 ][ 0 ] == 3 && theByte[ 0 ][ 1 ] == 0
- && theByte[ 0 ][ 2 ] == 0 && theByte[ 0 ][ 3 ] == 0
- && theByte[ 0 ][ 4 ] == 0 && theByte[ 1 ][ 0 ] == 0
- && theByte[ 1 ][ 1 ] == 0 && theByte[ 1 ][ 2 ] == 3
- && theByte[ 9 ][ 1 ] == 0 && theByte[ 9 ][ 2 ] == 0
- && theByte[ 9 ][ 3 ] == 0 && theByte[ 9 ][ 4 ] == 0
- && theByte[ 9 ][ 5 ] == 0 && theByte[ 8 ][ 0 ] == 0
- && theByte[ 8 ][ 1 ] == 0 && theByte[ 8 ][ 5 ] == 0
- && theByte[ 8 ][ 6 ] == 0 ) {
- return 3 ;
- } else if (theByte[ 0 ][ 1 ] == 0 && theByte[ 0 ][ 2 ] == 0
- && theByte[ 0 ][ 3 ] == 0 && theByte[ 0 ][ 4 ] == 0
- && theByte[ 0 ][ 5 ] == 0 && theByte[ 0 ][ 6 ] == 0
- && theByte[ 0 ][ 3 ] == 0 && theByte[ 1 ][ 3 ] == 0
- && theByte[ 2 ][ 3 ] == 0 && theByte[ 3 ][ 3 ] == 0
- && theByte[ 4 ][ 3 ] == 0 && theByte[ 5 ][ 3 ] == 0
- && theByte[ 6 ][ 3 ] == 0 && theByte[ 7 ][ 3 ] == 0
- && theByte[ 8 ][ 3 ] == 0 && theByte[ 9 ][ 3 ] == 0
- && theByte[ 0 ][ 4 ] == 0 && theByte[ 1 ][ 4 ] == 0
- && theByte[ 2 ][ 4 ] == 0 && theByte[ 3 ][ 4 ] == 0
- && theByte[ 4 ][ 4 ] == 0 && theByte[ 5 ][ 4 ] == 0
- && theByte[ 6 ][ 4 ] == 0 && theByte[ 7 ][ 4 ] == 0
- && theByte[ 8 ][ 4 ] == 0 && theByte[ 9 ][ 4 ] == 0 ) {
- return 1 ;
- } else if (theByte[ 0 ][ 5 ] == 0 && theByte[ 1 ][ 5 ] == 0
- && theByte[ 2 ][ 5 ] == 0 && theByte[ 3 ][ 5 ] == 0
- && theByte[ 4 ][ 5 ] == 0 && theByte[ 5 ][ 5 ] == 0
- && theByte[ 6 ][ 5 ] == 0 && theByte[ 7 ][ 5 ] == 0
- && theByte[ 8 ][ 5 ] == 0 && theByte[ 9 ][ 5 ] == 0
- && theByte[ 0 ][ 6 ] == 0 && theByte[ 1 ][ 6 ] == 0
- && theByte[ 2 ][ 6 ] == 0 && theByte[ 3 ][ 6 ] == 0
- && theByte[ 4 ][ 6 ] == 0 && theByte[ 5 ][ 6 ] == 0
- && theByte[ 6 ][ 6 ] == 0 && theByte[ 7 ][ 6 ] == 0
- && theByte[ 8 ][ 6 ] == 0 && theByte[ 9 ][ 6 ] == 0 ) {
- return 4 ;
- } else if (theByte[ 5 ][ 0 ] == 0 && theByte[ 6 ][ 0 ] == 0
- && theByte[ 7 ][ 0 ] == 0 && theByte[ 8 ][ 0 ] == 0
- && theByte[ 9 ][ 0 ] == 0 && theByte[ 5 ][ 1 ] == 0
- && theByte[ 6 ][ 1 ] == 0 && theByte[ 7 ][ 1 ] == 0
- && theByte[ 8 ][ 1 ] == 0 && theByte[ 9 ][ 1 ] == 0
- && theByte[ 9 ][ 2 ] == 0 && theByte[ 9 ][ 3 ] == 0
- && theByte[ 9 ][ 4 ] == 0 && theByte[ 9 ][ 5 ] == 0
- && theByte[ 9 ][ 6 ] == 0 && theByte[ 2 ][ 6 ] == 0
- && theByte[ 3 ][ 6 ] == 0 && theByte[ 4 ][ 6 ] == 0
- && theByte[ 5 ][ 6 ] == 0 && theByte[ 2 ][ 7 ] == 0 ) {
- return 5 ;
- } else if (theByte[ 2 ][ 0 ] == 0 && theByte[ 3 ][ 0 ] == 0
- && theByte[ 4 ][ 0 ] == 0 && theByte[ 5 ][ 0 ] == 0
- && theByte[ 6 ][ 0 ] == 0 && theByte[ 7 ][ 0 ] == 0
- && theByte[ 1 ][ 1 ] == 0 && theByte[ 2 ][ 1 ] == 0
- && theByte[ 3 ][ 1 ] == 0 && theByte[ 4 ][ 1 ] == 0
- && theByte[ 5 ][ 1 ] == 0 && theByte[ 6 ][ 1 ] == 0
- && theByte[ 7 ][ 1 ] == 0 && theByte[ 8 ][ 1 ] == 0 ) {
- return 6 ;
- } else if (theByte[ 9 ][ 0 ] == 0 && theByte[ 9 ][ 1 ] == 0
- && theByte[ 9 ][ 2 ] == 0 && theByte[ 9 ][ 3 ] == 00
- && theByte[ 9 ][ 4 ] == 0 && theByte[ 9 ][ 5 ] == 0
- && theByte[ 9 ][ 6 ] == 0 && theByte[ 9 ][ 7 ] == 0
- && theByte[ 8 ][ 7 ] == 0 && theByte[ 8 ][ 6 ] == 0
- && theByte[ 7 ][ 6 ] == 0 && theByte[ 7 ][ 7 ] == 0
- && theByte[ 6 ][ 6 ] == 0 && theByte[ 6 ][ 5 ] == 0
- && theByte[ 5 ][ 5 ] == 0 && theByte[ 5 ][ 4 ] == 0
- && theByte[ 4 ][ 4 ] == 0 ) {
- return 7 ;
- } else if (theByte[ 2 ][ 0 ] == 0 && theByte[ 3 ][ 0 ] == 0
- && theByte[ 7 ][ 0 ] == 0 && theByte[ 1 ][ 1 ] == 0
- && theByte[ 2 ][ 1 ] == 0 && theByte[ 3 ][ 1 ] == 0
- && theByte[ 4 ][ 1 ] == 0 && theByte[ 0 ][ 2 ] == 0
- && theByte[ 0 ][ 3 ] == 0 && theByte[ 0 ][ 4 ] == 0
- && theByte[ 1 ][ 5 ] == 0 && theByte[ 1 ][ 6 ] == 0
- && theByte[ 1 ][ 6 ] == 0 && theByte[ 4 ][ 2 ] == 0
- && theByte[ 5 ][ 2 ] == 0 && theByte[ 6 ][ 2 ] == 0 ) {
- return 8 ;
- } else if (theByte[ 1 ][ 6 ] == 0 && theByte[ 2 ][ 6 ] == 0
- && theByte[ 3 ][ 6 ] == 0 && theByte[ 4 ][ 6 ] == 0
- && theByte[ 5 ][ 6 ] == 0 && theByte[ 6 ][ 6 ] == 0
- && theByte[ 2 ][ 7 ] == 0 && theByte[ 3 ][ 7 ] == 0
- && theByte[ 4 ][ 7 ] == 0 && theByte[ 5 ][ 7 ] == 0
- && theByte[ 6 ][ 7 ] == 0 && theByte[ 7 ][ 7 ] == 0
- && theByte[ 5 ][ 5 ] == 0 && theByte[ 4 ][ 2 ] == 0
- && theByte[ 4 ][ 3 ] == 0 && theByte[ 4 ][ 4 ] == 0
- && theByte[ 2 ][ 1 ] == 0 ) {
- return 9 ;
- } else {
- return 0 ;
- }
- }
- private String parse4Num( byte [][] theByte) {
- int x = 0 ;
- int y = 0 ;
- String num;
- byte [][] numByte = new byte [ 10 ][ 8 ];
- for ( int i = 5 ; i < 15 ; i++) {
- for ( int j = 5 ; j < 13 ; j++) {
- numByte[x][y] = theByte[i][j];
- y++;
- }
- x++;
- y = 0 ;
- }
- num = "" + parse1Num(numByte);
- x = 0 ;
- y = 0 ;
- numByte = new byte [ 10 ][ 8 ];
- for ( int i = 5 ; i < 15 ; i++) {
- for ( int j = 14 ; j < 22 ; j++) {
- numByte[x][y] = theByte[i][j];
- y++;
- }
- x++;
- y = 0 ;
- }
- num += parse1Num(numByte);
- x = 0 ;
- y = 0 ;
- numByte = new byte [ 10 ][ 8 ];
- for ( int i = 5 ; i < 15 ; i++) {
- for ( int j = 23 ; j < 31 ; j++) {
- numByte[x][y] = theByte[i][j];
- y++;
- }
- x++;
- y = 0 ;
- }
- num += parse1Num(numByte);
- x = 0 ;
- y = 0 ;
- numByte = new byte [ 10 ][ 8 ];
- for ( int i = 5 ; i < 15 ; i++) {
- for ( int j = 32 ; j < 40 ; j++) {
- numByte[x][y] = theByte[i][j];
- y++;
- }
- x++;
- y = 0 ;
- }
- num += parse1Num(numByte);
- return num;
- }
- /**
- * @param args
- * @throws IOException
- */
- public static void main(String[] args) {
- BMPTest t = new BMPTest();
- t.handler( "D:\\eclipse2\\workspace\\BMPTest\\classes\\9834.bmp" );
- }
- public void handler(String fileName) {
- File bmpFile = new File(fileName);
- FileInputStream fis;
- BMPHeader header = new BMPHeader();
- BMPTest bt = new BMPTest();
- try {
- fis = new FileInputStream(bmpFile);
- fis.read(header.bm);
- fis.read(header.size);
- fis.read(header.save);
- fis.read(header.dataPos);
- fis.read(header.desSize);
- fis.read(header.width);
- fis.read(header.hight);
- fis.read(header.plane);
- fis.read(header.bytes);
- fis.read(header.zip);
- fis.read(header.picSize);
- fis.read(header.shuiPing);
- fis.read(header.cuiZhi);
- fis.read(header.colorNum);
- fis.read(header.colorTab);
- fis.read(header.bmpData);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- System.out.println( "The Picture is:"
- + bt.parse4Num(bt.parse960ToLine(header.bmpData)));
- }
- }
随机码图片格式确定 每位数字的位置都是确定的。。 现在网站上的随机码换成彩色的了
发表评论
-
过年没事,一天时间写了一个是男人就撑住20秒的Java版
2012-01-24 13:21 3747每年过年都没事,都得写点小东西,今年是是男人就撑过20秒(20 ... -
Where is my water 游戏算法
2012-01-23 19:56 2058过年把Where is my water完了一遍,对这个游戏的 ... -
假期没事,写了个90行的俄罗斯方块,Java实现,史上最小巧
2010-02-16 23:03 10972Bug已经Fix~~ 注释已经补充 import jav ... -
俄罗斯方块:C++中的常用错误原因~~
2008-07-20 20:45 1276很久没有用C++写程序了。。用起来很不顺手! 出了问题不知道怎 ... -
疯狂游戏系列之(一)疯狂俄罗斯策划
2008-07-18 20:38 1458闲来无事,做一个PSP上的俄罗斯方块游戏,大致原则是两个字 疯 ... -
PSP程序开发例子解析(十二)InputSystem
2008-07-14 20:50 1020InputSystem例子掩饰了如何在程序中输入文字 #i ... -
PSP程序开发例子解析(十一)HGEParticles
2008-07-14 20:50 1012HGEParticles这个例子很BT 模仿WindowsMe ... -
PSP程序开发例子解析(十)HGEDistortionMesh
2008-07-14 20:49 1642HGEDistortionMesh例子应用了HGE包中的内容 ... -
PSP程序开发例子解析(九)3DPrimer
2008-07-14 20:48 11933D例子显示一个Cube和一个人物 不断旋转 具体底部底层AP ... -
PSP程序开发例子解析(八)Animator
2008-07-14 20:48 921GameApp.cpp #include <std ... -
PSP程序开发例子解析(七)DisplayingChinese
2008-07-14 20:46 929显示中文 加载点阵文件 没啥说的 就是不清楚点阵文件是哪来的= ... -
PSP程序开发例子解析(六)TrueTypeFont
2008-07-14 20:45 1032按照Windows的ttf字体显示文字。。跑不起来 略 #i ... -
PSP程序开发例子解析(五)Shapes
2008-07-14 20:44 888绘制各种形状 无话可说 #include <st ... -
PSP程序开发例子解析(四)Splines
2008-07-14 20:38 925第四个例子讲述了曲线 ... -
PSP程序开发例子解析(三)ResourceManager
2008-07-14 20:38 929太晚了 明天再写 弄个res文件没找到 换了个工程 copy源 ... -
PSP程序开发例子解析(二)Images
2008-07-14 20:37 1115第二个例子程序演示了 ... -
PSP程序开发例子解析(一)HelloWorld
2008-07-14 20:31 2963今天晚上把PSP的开发环境搭建了起来 并且看了看PSP的Hel ...
相关推荐
可支持多种图片格式 (GIF/JPG/BMP/TIFF) ' 3。远程配置文件、图片远程路径 可支持多种读取方法或协议 (HTTP/FTP/共享路径/本地路径) ' 4。后台运行,占用系统资源小。(物理内存约 600KB,虚拟内存约 1400KB) '...
可支持多种图片格式 (GIF/JPG/BMP/TIFF) ' 3。远程配置文件、图片远程路径 可支持多种读取方法或协议 (HTTP/FTP/共享路径/本地路径) ' 4。后台运行,占用系统资源小。(物理内存约 600KB,虚拟内存约 1400KB) '...
允许一次性多图片格式(*.JPG/*.GIF/*.BMP/*.PNG),且支持模糊与非模糊方式导入图片,还可以在导入的图片上显示其文件名称以易于管理。 【批量导出图片】 将EXCEL中指定某列中的图片按显示图片大小导出到指定的...
允许一次性多图片格式(*.JPG/*.GIF/*.BMP/*.PNG),且支持模糊与非模糊方式导入图片,还可以在导入的图片上显示其文件名称以易于管理。 【批量导出图片】 将EXCEL中指定某列中的图片按显示图片大小导出到指定的...
5.水印,上传图时可以加水印,后台可以设置选择文字水印或图片水印,上传bmp图片时系统会自动压缩成jpg格式。6.管理员权限可以自由定义,自由定义管理员名称和职位7.回贴时可以加入投票、评论、活动等功,阅读权限,...
水印,上传图时可以加水印,后台可以设置选择文字水印或图片水印,上传bmp图片时系统会自动压缩成jpg格式。 6.管理员权限可以自由定义,自由定义管理员名称和职位 7.回贴时可以加入投票、评论、活动等功,阅读...
如何格式化日期 5.数组和集合 6.文件和目录(I/O)操作 如何列出某个目录下的所有文件 如何列出某个目录下的所有子目录 判断一个文件或目录是否存在 如何读写文件 7.Java多态的实现(继承、重载、覆盖) 8....
在用光盘安装系统时就需要对此部分进设置,第一驱动改为光驱引导(First Boot Device),否则光驱不会引导装系统。 Quick Power On Self Test(快速启动选择): 当设定为[Enabled](启动)时,这个项目在系统...
6、群发同附件邮件:将同标题、同内容、同附件的共性邮件群发到多个邮箱与手机,与邮箱群发不同的是能“逐个群发”,不受群发数量限制,不会被对方看到多个地址,不会被过滤成垃圾邮件。 7、自动进入网易邮箱:凡是...
9、修复了图片上传功能,支持上传的文件格式有:图片文件(*.gif、*.jpg、*.png、*.bmp),动画FLASH文件(*.swf) ----------------------------------------------- 功能介绍: 1、系统基本设置管理 网站名称/标题...