Bitmap bm = BitmapFactory.decodeByteArray
(_data, 0, _data.length);
picname = "sdcard/1234566.jpg";//要保存在哪里,路径你自己设
File myCaptureFile = new File(picname);
try
{
BufferedOutputStream bos = new BufferedOutputStream
(new FileOutputStream(myCaptureFile));
bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
bos.flush();
bos.close();
//mImageView01.setImageBitmap(bm);
resetCamera();
}
catch (Exception e)
{
Log.e(TAG, e.getMessage());
}
}
};
拍照完了要重置照相机,然后可以继续拍照
private void resetCamera()
{
if (mCamera01 != null && bIfPreview)
{
mCamera01.stopPreview();
mCamera01.release();
mCamera01 = null;
bIfPreview = false;
}
}
2种拍照方式的比较
1.调用系统自带的照相机,照片格式大小只有几种选择,照片拍出来比较大,而自己程序实现的话可以调节照片大小为任意尺寸,图片的容量可以调节
2.调用系统的简单,而且外观一般比自己设置的要好看
3.调用系统的操作简单、方便,不易出错,自己编程的话需要注意,容易引起系统出错意外终止。