求教BinCompiler在安卓下的使用方法

creamtank 2012-03-16 11:39:20
BinReader.java

package com.test;


import java.io.InputStream;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;





public class BinReader extends Activity {

//读取指定文件并返回字节数组
public byte[] readFile(String binfile, int pos)
{
byte buffer[];
int len;
try {
InputStream is = this.getClass().getResourceAsStream("/" + binfile);
is.skip(pos);
len = (is.read() & 0xFF) << 24;
len = (is.read() & 0xFF) << 16;
len = (is.read() & 0xFF) << 8;
len = (is.read() & 0xFF);
buffer = new byte[len];

is.read(buffer, 0, buffer.length);
is.close();
is = null;

System.gc();
} catch (Exception e) {
buffer = null;
e.printStackTrace();
System.gc();
return null;
}

return buffer;
}

/**************************************************************************************
* Reads a file from the BIN file and return data as an Image
**************************************************************************************/
public Bitmap readImage(String binfile, long pos)
{
byte buffer[];
int len;

try {
InputStream is = this.getClass().getResourceAsStream("/" + binfile);

is.skip(pos);

len = (is.read() & 0xFF) << 24;
len |= (is.read() & 0xFF) << 16;
len |= (is.read() & 0xFF) << 8;
len |= (is.read() & 0xFF);

buffer = new byte[len];

is.read(buffer, 0, buffer.length);

is.close();
is = null;

System.gc();
} catch (Exception e) {
buffer = null;
e.printStackTrace();
System.gc();
return null;
}

return BitmapFactory.decodeByteArray(buffer, 0, buffer.length);
}
}



Main.java中的调用方法

BinReader br;
Bitmap image;
br.readImage("image.bin", 0);


我有2张png的图 用BinCompiler压成一个二进制bin文件[image.bin]
想在安卓程序中显示,不用xml布局,

实在是找不到多少文档,资源啥的,
特来跪求高人帮忙啊~~~~
...全文
87 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
creamtank 2012-03-17
  • 打赏
  • 举报
回复
难道没人知道么????

80,493

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧