I am creating an Android application, but the device has a square screen. The 320x320 screen and camera app use SurfaceView to show a preview as shown below:
mCameraView = (SurfaceView) findViewById(R.id.surface); LayoutParams params = mCameraView.getLayoutParams(); int camera_dimension = getResources().getInteger(R.integer.camera_dimension); params.height = camera_dimension;
The surface has changed, I do it and it works, but the preview is w480 x h320
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { int mWidth = w; int mHeight = h; int mFormat = format; try { mCameraAccess.mCamera.stopPreview(); } catch (Exception e){
How can I make sure that my preview inside the viewer is not compressed, but some kind of center. Since the preview is a rectangle, I just need a square centered on the image. I usually use scaleType but not supported in Surface view
Any idea?
android android-camera surfaceview
Seb
source share