5
안드로이드 타블렛을 코딩 중이며 내 응용 프로그램에서 surfaceView
카메라 미리보기의 세로보기를 사용하도록하고 싶습니다. 기본적으로 가로보기이며 세로보기로 회전하려면 다음 코드를 시도했습니다.안면보기에서 Android 카메라를 세로로 변경하는 방법은 무엇입니까?
public void surfaceCreated(SurfaceHolder holder){
// The Surface has been created, acquire the camera and tell it where to draw.
mCamera = Camera.open();
Parameters params = mCamera.getParameters();
// If we aren't landscape (the default), tell the camera we want portrait mode
if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE){
params.set("orientation", "portrait"); // "landscape"
// And Rotate the final picture if possible
// This works on 2.0 and higher only
//params.setRotation(90);
// Use reflection to see if it exists and to call it so you can support older versions
try {
Method rotateSet = Camera.Parameters.class.getMethod("setRotation", new Class[] { Integer.TYPE });
Object arguments[] = new Object[] { new Integer(270) };
rotateSet.invoke(params, arguments);
} catch (NoSuchMethodException nsme) {
// Older Device
Log.v("CameraView","No Set Rotation");
} catch (IllegalArgumentException e) {
Log.v("CameraView","Exception IllegalArgument");
} catch (IllegalAccessException e) {
Log.v("CameraView","Illegal Access Exception");
} catch (InvocationTargetException e) {
Log.v("CameraView","Invocation Target Exception");
}
}
mCamera.setParameters(params);
try{
mCamera.setPreviewDisplay(holder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
}
}
그러나 작동하지 않습니다. 아무도 그것을 고칠 수 있을까요? 카메라 params.set("orientation"...
물건을 사용
public void surfaceCreated(SurfaceHolder holder) {
if (Build.VERSION.SDK_INT >= 8) mCamera.setDisplayOrientation(90);
}
장치에서 일치하지 않습니다 정말 사전 SDK 8 언어 : 다음과 같이
또한 Object arguments로 시도했습니다. [] = new Object [] {new Integer (90)}; 그러나 나는 아직도 그것을 고칠 수 없었다. –
표면 뷰를 사용 했으므로 예제를 제공해 줄 수 있습니까? ipcamera에서 내 안드로이드로 스트리밍해야하며 표면보기를 사용하고 싶습니다. – Lily