Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

NPE while setting the aspect ratio #272

@doruchidean-lifeishard

Description

@doruchidean-lifeishard

I'm trying to set the aspect ratio for the preview like so:

       @Override
        public void onCameraOpened(CameraView cameraView) {
            super.onCameraOpened(cameraView);
            for (AspectRatio ar : cameraView.getSupportedAspectRatios()) {
                if (ar.getX() == 3 && ar.getY() == 2) {
                    cameraView.setAspectRatio(ar);  //NPE exception
                    break;
                }
            }
        }

and I get a NPE exception:
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.SortedSet.last()' on a null object reference
at com.google.android.cameraview.Camera1.adjustCameraParameters(Camera1.java:333)
at com.google.android.cameraview.Camera1.setAspectRatio(Camera1.java:174)
at com.google.android.cameraview.CameraView.setAspectRatio(CameraView.java:346)

What I'm trying to accomplish is to have the same aspectRatio for the preview and the resulted bitmap (so I can crop the photo on a specific location)
Is there another way to accomplish this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions