网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 移动短信技术
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.编写SMS程序入门.
.Windows CE.Net下矩阵键盘开发设.
.基于Nokia S60的游戏开发之一.
.利用手机模块实现短消息(二).
.一个文本转2进制的函数.
.联通SGIP模拟网关.
.基于短信网关WAP推送的实现.
.ERICSSON多媒体实验室提供的MMS和.
.英斯克的网关模拟器.
.MIDP2.0手机上手电筒程序的实现.
.Windows Mobile开发环境搭建指南.
.为Nokia S60编写移动游戏之二.
.短信网关在短信信息服务中的作用.
.用C#设计在局域网发送短信的程序.
.基于SMPP协议的GSM短消息增值业务.
.在PC上通过手机发送短消息.
.NOKIA、MOTOROLA、SIMENS及ERICC.
.西门子图片比较粗糙的一个算法.
.CMPP ACTIVETEST RESPONSE.
.NOKIA 铃声图片方面的标准文档.

EMS图片格式转换(Java)程序

发表日期:2003-2-14


本人刚接触EMS,还有很多地方不明
这个程序对16*16,32*32,72*14有效,可直接得到要发送的byte[140],40*35还没测试,本着公开源码的精神,献丑了

//victorachc@163.com
import java.io.*;

public class preResult{
//pos is the pixel data start postion
private int pos;
//bitmap's width and height
private byte w;
private byte h;
//bmp is byte[] of the bmp file
private byte[] bmp;
//result is the byte[] which save the result
private byte[] result = new byte[140];
//result[] length
private int rlen;

protected  preResult(String fn) throws IOException {
FileInputStream fin = new FileInputStream(fn);
//read bmpdata to byte array bmp
int bmplen = fin.available();
bmp = new byte[bmplen];
fin.read(bmp);
w=bmp[18];
h=bmp[22];
fin.close();
}

//check if it is 1 bit/pixel
public void isValid() throws Exception {
if(bmp[28]==1) return;
else  throw new Exception("pixel is not 1");
}

//check if the bmp length is valid
public boolean checkDataLen() throws Exception {
int len=(bmp[2]-bmp[10])>=0?(bmp[2]-bmp[10]):(bmp[2]-bmp[10]+256);
if (len==(w*h/8)){
return true;
}
else if(len*3/4==w*h/8){
System.out.println("This is variable bmp!");
return true;
}
else throw new Exception("length is invalid");
}

public void getHead() throws Exception {
if(w==16&&h==16){
result[0]=35;
result[1]=17;
result[2]=33;
result[3]=0;
pos=4;
rlen=36;
return;
}
else if(w==32&&h==32){
result[0]=-125;
result[1]=16;
result[2]=-127;
result[3]=0;
pos=4;
rlen=132;
return;
}
else if(((w%8)==0)&&((w*h)<=1024)){
int p=w*h/8+5;
result[0]=(byte)((p<=127)?p:(p-256));
result[1]=18;
result[2]=(byte)(result[0]-2);
result[3]=0;
result[4]=(byte)(w/8);
result[5]=h;
pos=6;
rlen=p+1;
return;
}
throw new Exception("header error");
}

public void getBody(){
//according to the EMS specification,w is w/8
int wid=w/8;
if(pos==4){
//lh is loop height,lw is loop width
for(int lh=0;lh<h;lh++){
for(int i=bmp.length-(lh+1)*wid;i<bmp.length-lh*wid;i++){
result[pos] = bmp[i];
pos++;
}
}
}
else if(pos==6){
wid = wid+3;
for(int lh=0;lh<h;lh++){
for(int i=bmp.length-(lh+1)*wid;i<bmp.length-lh*wid;i++){
if(i<bmp.length-lh*wid-3){
result[pos] = bmp[i];
pos++;
}
}
}
}
//result has been build,you can check the byte[] here
}

public void putResultIntoFile() throws IOException{
FileOutputStream fout = new FileOutputStream("test.tmp");
fout.write(result);
fout.close();
}

public static void main(String[] args) throws IOException,Exception {
preResult pR = new preResult("d:\\Tom.bmp");
pR.isValid();
try{
pR.checkDataLen();
}
catch(Exception e){e.printStackTrace();}
pR.getHead();
pR.getBody();
pR.putResultIntoFile();
}
}

这段程序参考了斑竹:BMP结构!  的帖子,不正确的地方,请指教!

上一篇:图片格式整理(增加alcatel) 人气:11350
下一篇:MIDI文件结构分析及生成方法 人气:12391
浏览全部的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐