다음과 같은 문제가 있습니다. 카메라와 그 위에 앱이 있고 오버레이로 이미지가있는 앱이 있습니다. 이미지가 4/3에 있습니다. 화면에 최적의 크기를 얻었고 이미지를 그립니다. 문제는 내가 시도 할 때 모든 이미지가 보이지 않는다는 것입니다. 화면 상단과 하단에 이미지가 잘려 있습니다. 문제는 내가 사진을 찍으면 사진이 완벽하다는 것입니다.Android 오버레이 4/3 카메라의 이미지
나는 안드로이드 SDK 8을 사용하고 있으며 카메라는 가로 모드에 있습니다. 삼성 갤럭시 S에서는 오버레이와 표면 미리보기가 같은 크기 인 640 : 480을 제공합니다.
나는 한동안 놀았으며 아직 해결책을 찾지 못했습니다.
다음은 코드입니다.
내 XML : 내 코드의
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/framecamera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center"
android:padding="0dip"
android:layout_margin="0dip"
>
<FrameLayout
android:id="@+id/surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dip"
android:layout_margin="0dip"
>
</FrameLayout>
<ImageButton
android:id="@+id/button_capture"
android:contentDescription="@string/click"
android:text="@string/click"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:background="@drawable/camera"
android:src="@drawable/camera"
/>
</LinearLayout>
중요한 부분 :
setContentView(R.layout.camera);
//create an instance of Camera
mcam = getCameraInstance();
Camera.Parameters parameters=mcam.getParameters();
size=getBestPreviewSize(parameters);//gets the 4/3 size
horizontal = Bitmap.createScaledBitmap(horizontal, size.width, size.height, false);
// Create our Preview view and set it as the content of our activity.
mpreview = new CameraPreview(getBaseContext(), mcam);
FrameLayout frame = (FrameLayout) findViewById(R.id.surface);
SurfaceHolder mSurfaceHolder = mpreview.getHolder();
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//set our view to 4:3
ViewGroup.LayoutParams params = frame.getLayoutParams();
params.width = size.width;
params.height = size.height;
frame.setLayoutParams(params);
//add the necessary margin to the view
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
MarginLayoutParams ps=(MarginLayoutParams)frame.getLayoutParams();
ps.topMargin = 0;
ps.bottomMargin = 0;
ps.leftMargin = (display.getWidth()-size.width)/2;//to center the overlay
frame.setLayoutParams(ps);
frame.addView(mpreview);
over = new OverlayPreview(getBaseContext(),horizontal);//inside I draw the canvas
frame.addView(over);
어떤 아이디어가 크게 감상 할 수있다. 문제는 패딩 어쩌면 또는 XML에서 온 것 같아요하지만 그것을 수정하는 방법을 모르겠습니다. 고맙습니다.
p.d : 제 첫 번째 언어가 아닌 제 영어는 유감입니다.