Add doMetering parameter

pull/580/head
Mattia Iavarone 6 years ago
parent 02a04c1874
commit ee1c4f9cd5
  1. 4
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/MockCameraEngine.java
  2. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java
  3. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java
  4. 9
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java

@ -123,12 +123,12 @@ public class MockCameraEngine extends CameraEngine {
}
@Override
protected void onTakePicture(@NonNull PictureResult.Stub stub) {
protected void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering) {
}
@Override
protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio) {
protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering) {
}

@ -297,7 +297,7 @@ public class Camera1Engine extends CameraEngine implements
@WorkerThread
@Override
protected void onTakePicture(@NonNull PictureResult.Stub stub) {
protected void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering) {
stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR);
stub.size = getPictureSize(Reference.OUTPUT);
mPictureRecorder = new Full1PictureRecorder(stub, Camera1Engine.this, mCamera);
@ -306,7 +306,7 @@ public class Camera1Engine extends CameraEngine implements
@WorkerThread
@Override
protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio) {
protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering) {
stub.size = getUncroppedSnapshotSize(Reference.OUTPUT); // Not the real size: it will be cropped to match the view ratio
stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR); // Actually it will be rotated and set to 0.

@ -610,7 +610,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
@WorkerThread
@Override
protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio) {
protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering) {
stub.size = getUncroppedSnapshotSize(Reference.OUTPUT); // Not the real size: it will be cropped to match the view ratio
stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR); // Actually it will be rotated and set to 0.
if (mPreview instanceof GlCameraPreview) {
@ -622,7 +622,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
}
@Override
protected void onTakePicture(@NonNull PictureResult.Stub stub) {
protected void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering) {
stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR);
stub.size = getPictureSize(Reference.OUTPUT);
try {

@ -1088,7 +1088,6 @@ public abstract class CameraEngine implements
public void run() {
LOG.v("takePicture", "performing. BindState:", getBindState(), "isTakingPicture:", isTakingPicture());
if (mMode == Mode.VIDEO) {
// Could redirect to takePictureSnapshot, but it's better if people know what they are doing.
throw new IllegalStateException("Can't take hq pictures while in VIDEO mode");
}
if (getBindState() < STATE_STARTED) return;
@ -1096,7 +1095,7 @@ public abstract class CameraEngine implements
stub.isSnapshot = false;
stub.location = mLocation;
stub.facing = mFacing;
onTakePicture(stub);
onTakePicture(stub, mPictureMetering);
}
});
}
@ -1120,7 +1119,7 @@ public abstract class CameraEngine implements
// Leave the other parameters to subclasses.
//noinspection ConstantConditions
AspectRatio ratio = AspectRatio.of(getPreviewSurfaceSize(Reference.OUTPUT));
onTakePictureSnapshot(stub, ratio);
onTakePictureSnapshot(stub, ratio, mPictureSnapshotMetering);
}
});
}
@ -1241,10 +1240,10 @@ public abstract class CameraEngine implements
}
@WorkerThread
protected abstract void onTakePicture(@NonNull PictureResult.Stub stub);
protected abstract void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering);
@WorkerThread
protected abstract void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio);
protected abstract void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering);
@WorkerThread
protected abstract void onTakeVideoSnapshot(@NonNull VideoResult.Stub stub, @NonNull AspectRatio outputRatio);

Loading…
Cancel
Save