JSONObject jsonObject = (JSONObject)jsonArray.opt(i);
ResultEntity re = new ResultEntity();e.printStackTrace();
}
//保存一副图片函数
int MAXIMGSIZE = 655360;
int SaveRawToBmp(byte[] Rawdata, StringfileName, int sensorType)
{
byte[]bmp_head_640x480 = {
0x42,0x4D, 0x38, (byte)0xC3, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00,0x00, 0x28, 0x00,
0x00,0x00, (byte)0x80, 0x02, 0x00, 0x00, (byte)0xE0, 0x01, 0x00, 0x00, 0x01, 0x00,0x08, 0x00, 0x00, 0x00,
0x00,0x00, 0x02, (byte)0xB0, 0x04, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,0x00, 0x00, 0x00};
byte[]bmp_head_256x360 = {
0x42,0x4D, 0x36, 0x6C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00,0x28, 0x00,
0x00,0x00, 0x00, 0x01, 0x00, 0x00, 0x68, 0x01, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00,0x00, 0x00,
0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x01};
byte[]bmp_colmap = {00, 00, 00, 00};
byte[]fixarray = new byte[1024];
for(inti=0; i<1024; i++)
fixarray[i]= 0;
try {
//FileOutputStream 用于写入诸如图像数据之类的原始字节的流。要写入字符流,请考虑使用 FileWriter。
FileOutputStreamstream = new FileOutputStream(fileName);
if( sensorType == 1) //xxx
{
stream.write(bmp_head_640x480);
stream.write(bmp_colmap,0, 3);
stream.write(bmp_colmap,0, 3);
for(inti=0; i<480; i++)
{
bmp_colmap[0]= bmp_colmap[1] = bmp_colmap[2] = (byte)i;
stream.write(bmp_colmap);
}
stream.write(Rawdata); //直接写入即可
}
else if( sensorType== 2 ) // xxx
{
stream.write(bmp_head_256x360);
stream.write(bmp_colmap,0, 3);
stream.write(bmp_colmap,0, 3);
for(inti=0; i<256; i++)
{
bmp_colmap[0]= bmp_colmap[1] = bmp_colmap[2] = (byte)i;
stream.write(bmp_colmap);
}
//BMP颠倒顺序写入即可
for(inti=0; i<360; i++)
{
stream.write(Rawdata,(360-1-i)*256, 256);
}
}
stream.close();
//Log.d(TAG,"SaveRawToBmp(bytes): " + oklen);
} catch(FileNotFoundException e) {
return -2;
} catch (IOException e){
return -1;
}
return 0;
}