ANDROID ov9650 數據格式 是RGB565??
如題。我在應用層 通過 public void onPreviewFrame(byte[] data, Camera camera){},中data 的數據格式是 565的?
如何保存將這byte[] data數據保存爲圖片呢? 数据格式客户是可以自己设的,不一定是RGB565. wbz073 发表于 2013-8-14 17:49 static/image/common/back.gif
数据格式客户是可以自己设的,不一定是RGB565.
現在的數據格式已經是RGB565了。那 public void onPreviewFrame(byte[] data, Camera camera){}中能否用byte[] data 保存爲圖片呢?
我都方法是將 rgb555的數據轉換成 ARGB888,再保存,但是保存都圖片失真很嚴重!附代碼:int tmpColor[] = new int;
for(int j=0; j<width*height;j++){
int tmpint = data+data*256;
int a = 0xff;
int r = (tmpint & 0xf800) >> 11;
int g = (tmpint & 0x07e0) >> 5;
int b = (tmpint & 0x001f);
r= r << 3;
g= g << 2 ;
b= b << 3;
tmpColor = (a << 24) | (r << 16) | (g << 8) | (b);
}
Bitmap bmp = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
bmp.setPixels(tmpColor, 0, width, 0, 0, width, height);
String bmpName = "t.jpg";
String path ="/scan_test";
System.out.println("########### path = " + path);
// 文件目录
File root = new File(path);
if (!root.isDirectory() || !root.exists()) {
root.mkdirs();
}
File myCaptureFile = new File(path, bmpName);
try {
myCaptureFile.createNewFile();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(myCaptureFile));
// 采用压缩转档方法
bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} catch (Exception e) {
myCaptureFile.delete();
}
页:
[1]