在我尝试过的所有手机上,包括具有 API 2.3.7 和 4.0 的 Galaxy Nexus,在 takePicture 方法被称为表面视图更改为所拍摄的图像后,即“图像审查”。
我已经在这些平板设备上进行了测试,但没有显示图像审查: XOOM API 3.1 Galaxy Tab 10.1 API 3.1 Galaxy Tab 10.1 API 3.2
surfaceView = (SurfaceView)findViewById(R.id.surfaceView);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
...
public void takePicture() {
cam.takePicture(this, null, this); //Shuttercallback, RawCallback, JpegCallback
}
...
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// Stop preview before changing camera parameters
if(isPreviewRunning) {
this.cam.stopPreview();
}
Camera.Parameters p = this.cam.getParameters();
LogUtils.info("CheckCapture", "Preview Size: " + String.valueOf(width) +"x" + String.valueOf(height));
p.setPreviewSize(width, height);
//Set picture size to a multiple of previewSize to maintain aspect ratio AND minimum capture width
//LogUtils.info("CheckCapture", "Picture Size: " + String.valueOf(width*factor) +"x" + String.valueOf(height*factor));
p.setPictureSize(width, height);
p.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
//Set picture format (we can check device capabilities, but all devices at API level 8 should support JPEG)
p.setPictureFormat(PixelFormat.JPEG);
//Set new camera parameters
try {
this.cam.setParameters(p);
}catch (Exception e) {
e.printStackTrace();
}
//Setup preview display on our surfaceViewHolder
try {
this.cam.setPreviewDisplay(surfaceHolder);
} catch (IOException e) {
e.printStackTrace();
}
//Start preview
this.cam.startPreview();
this.isPreviewRunning = true;
}