mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-24 01:38:18 +00:00
fix(picture-size): create None default value
This commit is contained in:
parent
92e8ececc9
commit
ad87c8e342
@ -242,9 +242,16 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
|
||||
|
||||
@Override
|
||||
void setPictureSize(Size size) {
|
||||
mPictureSize = size;
|
||||
if (size == null) {
|
||||
if (mAspectRatio == null) {
|
||||
return;
|
||||
}
|
||||
mPictureSize = mPictureSizes.sizes(mAspectRatio).last();
|
||||
} else {
|
||||
mPictureSize = size;
|
||||
}
|
||||
if (mCameraParameters != null && mCamera != null) {
|
||||
mCameraParameters.setPictureSize(size.getWidth(), size.getHeight());
|
||||
mCameraParameters.setPictureSize(mPictureSize.getWidth(), mPictureSize.getHeight());
|
||||
mCamera.setParameters(mCameraParameters);
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,14 @@ class Camera2 extends CameraViewImpl implements MediaRecorder.OnInfoListener, Me
|
||||
if (mStillImageReader != null) {
|
||||
mStillImageReader.close();
|
||||
}
|
||||
mPictureSize = size;
|
||||
if (size == null) {
|
||||
if (mAspectRatio == null) {
|
||||
return;
|
||||
}
|
||||
mPictureSizes.sizes(mAspectRatio).last();
|
||||
} else {
|
||||
mPictureSize = size;
|
||||
}
|
||||
prepareStillImageReader();
|
||||
startCaptureSession();
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class CameraViewManager extends ViewGroupManager<RNCameraView> {
|
||||
|
||||
@ReactProp(name = "pictureSize")
|
||||
public void setPictureSize(RNCameraView view, String size) {
|
||||
view.setPictureSize(Size.parse(size));
|
||||
view.setPictureSize(size.equals("None") ? null : Size.parse(size));
|
||||
}
|
||||
|
||||
@ReactProp(name = "barCodeTypes")
|
||||
|
@ -127,30 +127,38 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
|
||||
int correctWidth = width;
|
||||
int correctHeight = height;
|
||||
byte[] correctData = data;
|
||||
if (correctRotation == 90) {
|
||||
correctWidth = height;
|
||||
correctHeight = width;
|
||||
correctData = rotateImage(data, correctHeight, correctWidth);
|
||||
boolean willCallBarCodeTask = mShouldScanBarCodes && !barCodeScannerTaskLock && cameraView instanceof BarCodeScannerAsyncTaskDelegate;
|
||||
boolean willCallFaceTask = mShouldDetectFaces && !faceDetectorTaskLock && cameraView instanceof FaceDetectorAsyncTaskDelegate;
|
||||
boolean willCallGoogleBarcodeTask = mShouldGoogleDetectBarcodes && !googleBarcodeDetectorTaskLock && cameraView instanceof BarcodeDetectorAsyncTaskDelegate;
|
||||
boolean willCallTextTask = mShouldRecognizeText && !textRecognizerTaskLock && cameraView instanceof TextRecognizerAsyncTaskDelegate;
|
||||
if (!willCallBarCodeTask && !willCallFaceTask && !willCallGoogleBarcodeTask && !willCallTextTask) {
|
||||
return;
|
||||
}
|
||||
if (mShouldScanBarCodes && !barCodeScannerTaskLock && cameraView instanceof BarCodeScannerAsyncTaskDelegate) {
|
||||
|
||||
if (correctRotation == 90) {
|
||||
correctWidth = height;
|
||||
correctHeight = width;
|
||||
correctData = rotateImage(data, correctHeight, correctWidth);
|
||||
}
|
||||
if (willCallBarCodeTask) {
|
||||
barCodeScannerTaskLock = true;
|
||||
BarCodeScannerAsyncTaskDelegate delegate = (BarCodeScannerAsyncTaskDelegate) cameraView;
|
||||
new BarCodeScannerAsyncTask(delegate, mMultiFormatReader, correctData, correctWidth, correctHeight).execute();
|
||||
}
|
||||
|
||||
if (mShouldDetectFaces && !faceDetectorTaskLock && cameraView instanceof FaceDetectorAsyncTaskDelegate) {
|
||||
if (willCallFaceTask) {
|
||||
faceDetectorTaskLock = true;
|
||||
FaceDetectorAsyncTaskDelegate delegate = (FaceDetectorAsyncTaskDelegate) cameraView;
|
||||
new FaceDetectorAsyncTask(delegate, mFaceDetector, correctData, correctWidth, correctHeight, correctRotation).execute();
|
||||
}
|
||||
|
||||
if (mShouldGoogleDetectBarcodes && !googleBarcodeDetectorTaskLock && cameraView instanceof BarcodeDetectorAsyncTaskDelegate) {
|
||||
if (willCallGoogleBarcodeTask) {
|
||||
googleBarcodeDetectorTaskLock = true;
|
||||
BarcodeDetectorAsyncTaskDelegate delegate = (BarcodeDetectorAsyncTaskDelegate) cameraView;
|
||||
new BarcodeDetectorAsyncTask(delegate, mGoogleBarcodeDetector, correctData, correctWidth, correctHeight, correctRotation).execute();
|
||||
}
|
||||
|
||||
if (mShouldRecognizeText && !textRecognizerTaskLock && cameraView instanceof TextRecognizerAsyncTaskDelegate) {
|
||||
if (willCallTextTask) {
|
||||
textRecognizerTaskLock = true;
|
||||
TextRecognizerAsyncTaskDelegate delegate = (TextRecognizerAsyncTaskDelegate) cameraView;
|
||||
new TextRecognizerAsyncTask(delegate, mTextRecognizer, correctData, correctWidth, correctHeight, correctRotation).execute();
|
||||
|
@ -616,6 +616,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
||||
- (void)updateSessionPreset:(AVCaptureSessionPreset)preset
|
||||
{
|
||||
#if !(TARGET_IPHONE_SIMULATOR)
|
||||
if ([preset integerValue] < 0) {
|
||||
return;
|
||||
}
|
||||
if (preset) {
|
||||
if (self.isDetectingFaces && [preset isEqual:AVCaptureSessionPresetPhoto]) {
|
||||
RCTLog(@"AVCaptureSessionPresetPhoto not supported during face detection. Falling back to AVCaptureSessionPresetHigh");
|
||||
|
@ -134,7 +134,8 @@ RCT_EXPORT_VIEW_PROPERTY(onPictureSaved, RCTDirectEventBlock);
|
||||
@"Photo" : AVCaptureSessionPresetPhoto,
|
||||
@"High" : AVCaptureSessionPresetHigh,
|
||||
@"Medium" : AVCaptureSessionPresetMedium,
|
||||
@"Low" : AVCaptureSessionPresetLow
|
||||
@"Low" : AVCaptureSessionPresetLow,
|
||||
@"None": @(-1),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
|
||||
captureAudio: false,
|
||||
useCamera2Api: false,
|
||||
playSoundOnCapture: false,
|
||||
pictureSize: '1920x1080',
|
||||
pictureSize: 'None',
|
||||
videoStabilizationMode: 0,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user