Skip to content

Commit

Permalink
default aspect ratio
Browse files Browse the repository at this point in the history
display orientation
  • Loading branch information
ferdian-s committed Jun 22, 2018
1 parent 70b7bca commit 0ac1006
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.hardware.Camera;
import android.os.Build;
import android.support.v4.util.SparseArrayCompat;
import android.util.Log;
import android.view.SurfaceHolder;

import java.io.IOException;
Expand Down Expand Up @@ -117,6 +118,7 @@ void setUpPreview() {
}
mCamera.setPreviewDisplay(mPreview.getSurfaceHolder());
if (needsToStopPreview) {
mCamera.setDisplayOrientation(90);
mCamera.startPreview();
}
} else {
Expand Down Expand Up @@ -169,7 +171,8 @@ boolean setAspectRatio(AspectRatio ratio) {
} else if (!mAspectRatio.equals(ratio)) {
final Set<Size> sizes = mPreviewSizes.sizes(ratio);
if (sizes == null) {
throw new UnsupportedOperationException(ratio + " is not supported");
ratio = AspectRatio.of(4, 3);
Log.d("AspectRatio", ratio + " is not supported. switch to default 4:3");
} else {
mAspectRatio = ratio;
adjustCameraParameters();
Expand Down Expand Up @@ -245,6 +248,7 @@ public void onPictureTaken(byte[] data, Camera camera) {
isPictureCaptureInProgress.set(false);
mCallback.onPictureTaken(data);
camera.cancelAutoFocus();
camera.setDisplayOrientation(90);
camera.startPreview();
}
});
Expand All @@ -266,6 +270,7 @@ void setDisplayOrientation(int displayOrientation) {
}
mCamera.setDisplayOrientation(calcDisplayOrientation(displayOrientation));
if (needsToStopPreview) {
mCamera.setDisplayOrientation(90);
mCamera.startPreview();
}
}
Expand Down Expand Up @@ -342,6 +347,7 @@ void adjustCameraParameters() {
setFlashInternal(mFlash);
mCamera.setParameters(mCameraParameters);
if (mShowingPreview) {
mCamera.setDisplayOrientation(90);
mCamera.startPreview();
}
}
Expand Down

0 comments on commit 0ac1006

Please sign in to comment.