Skip to content

Commit 11eb1f6

Browse files
authored
feat: Use yuv by default if no pixelFormat is set (#2441)
1 parent 7e2889c commit 11eb1f6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

package/src/Camera.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
470470
}
471471

472472
const shouldEnableBufferCompression = props.video === true && frameProcessor == null
473+
const pixelFormat = props.pixelFormat ?? (frameProcessor == null ? 'yuv' : 'native')
473474
const torch = this.state.isRecordingWithFlash ? 'on' : props.torch
474475

475476
return (
@@ -487,6 +488,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
487488
codeScannerOptions={codeScanner}
488489
enableFrameProcessor={frameProcessor != null}
489490
enableBufferCompression={props.enableBufferCompression ?? shouldEnableBufferCompression}
491+
pixelFormat={pixelFormat}
490492
/>
491493
)
492494
}

package/src/CameraProps.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export interface CameraProps extends ViewProps {
7474
* - `yuv`: The YUV (Y'CbCr 4:2:0 or NV21, 8-bit) format, either video- or full-range, depending on hardware capabilities. This is the second most efficient format.
7575
* - `rgb`: The RGB (RGB, RGBA or ABGRA, 8-bit) format. This is least efficient and requires explicit conversion.
7676
*
77-
* @default `native`
77+
* @default
78+
* - Without a Frame Processor: `native`
79+
* - With a Frame Processor: `yuv`
7880
*/
7981
pixelFormat?: 'native' | 'yuv' | 'rgb'
8082
//#endregion

0 commit comments

Comments
 (0)