在我所嘗試的所有手機上,包括帶有API 2.3.7和4.0的Galaxy Nexus在調用takePicture方法之後,表面視圖會更改爲拍攝的圖像, 「圖像評論」。圖片審查未顯示在camera.take圖片
我對這些平板設備測試和圖像查看沒露面: 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;
}
這似乎是一個問題,我有[這裏](http://stackoverflow.com/questions/11676726/its-a-kind-of-magic-videoview-and-displaying-videos- on-android-3-1-vs-4-1),但帶有視頻和相同的設備。你修好了嗎? – 2dvisio 2012-07-26 22:11:50
不幸的是我放棄了,採取了類似於dinesh的方法。從捕獲中獲取圖像並將其顯示在ImageView中,例如'imageView.setImageBitmap(ImageUtils.jpegDecode(data));' – 2012-09-13 18:20:43