Decrease camera quality natively for android with react-native

32 Views Asked by At

Is there any way I can specify the resolution of the android camera using a react native module? The lib I'm using doesn't have this possibility to configure the camera, I wanted to do something native so that when the lib called the camera it was already at a reduced quality

I found this example on the internet but it didn't work for me, did I do something wrong?

    @ReactMethod
    public void setCameraResolution(int width, int height) {
        CameraManager cameraManager = (CameraManager) reactContext.getSystemService(reactContext.CAMERA_SERVICE);
        try {
            String cameraId = cameraManager.getCameraIdList()[0];
            CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId);
            StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

            
            Size closestSize = getClosestSize(map.getOutputSizes(Surface.class), width, height);

           
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
0

There are 0 best solutions below