www.wapease.com ·新闻动态 ·技术专题 ·WAP开发 ·用户专区 ·企业专区 ·相关资源 ·网络知识
首页>技术专题>SMS技术>正文    

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


WAP技术站:www.wapease.com  将本文推荐给你的QQ或MSN好友 加入收藏
本人刚接触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;

本新闻共2页,当前在第1页  1  2  

上一篇:图片格式整理(增加alcatel)
下一篇:MIDI文件结构分析及生成方法
Google
 
关于“EMS图片格式转换(Java)程序”的相关内容连接
·汉字不同编码转换的问题 UCS2转码的心得
·短信系统的所应有的功能
·短消息网关通信模块的设计与实现
·如何构建固定网(PSTN)短消息系统
·SMS方式远程监控软件的设计与实现
·短消息业务系统的架构与协议
·短信平台所需要的硬件配置
·编写SMS程序入门
·CMPP2.0协议升级
·用C#完成的QuerySMStatusA(华为API)

万易网(wapease.com)版权所有  服务声明

Copyright © 2003-2008 Wapease Network, All Rights Reserved