相机
相机打开 camera = Camera.open();
获取相机参数 Camera.Parameters params = camera.getParameters();
常用设置:
预览界面:preview-size-values=800,480 支持范围内
每秒捕获次数:preview-frame-rate=5
图片输出格式:picture-format=jpeg
照片大小: icture-size-values=支持范围内
Log.i("Camera参数",params.flatten());
释放相机
if(camera!=null){ camera.release(); }
实例
private final class SurfaceCallBack implements SurfaceHolder.Callback{ @Override public void surfaceCreated(SurfaceHolder surfaceHolder) { camera = Camera.open(); Camera.Parameters params = camera.getParameters(); params.setPreviewSize(800,480); params.setPreviewFpsRange(5,5); params.setPictureSize(2014,768); params.setJpegQuality(80); camera.setParameters(params); try { camera.setPreviewDisplay(surfaceHolder); camera.startPreview();//开始预览 } catch (IOException e) { e.printStackTrace(); } } @Override public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) { } @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { if(camera!=null){ camera.release(); } } }