ResolutionInfo


public class ResolutionInfo


A ResolutionInfo allows the application to know the resolution information of a specific use case.

Applications can know the resolution information of Preview before a SurfaceRequest is received, or know the resolution information of ImageAnalysis before an ImageProxy is received from ImageAnalysis.Analyzer.

Summary

Public constructors

ResolutionInfo(
    @NonNull Size resolution,
    @NonNull Rect cropRect,
    int rotationDegrees
)

Creates a new instance of ResolutionInfo with the given parameters.

Public methods

boolean
@NonNull Rect

Returns the crop rectangle.

@NonNull Size

Returns the output resolution used for the use case.

int

Returns the rotation degrees needed to transform the output resolution to the target rotation.

int
@NonNull String

Public constructors

ResolutionInfo

Added in 1.3.0
public ResolutionInfo(
    @NonNull Size resolution,
    @NonNull Rect cropRect,
    int rotationDegrees
)

Creates a new instance of ResolutionInfo with the given parameters. This constructor is not normally needed outside of testing cases.

Parameters
@NonNull Size resolution

The resolution used for the UseCase expressed in the coordinates of the camera sensor.

@NonNull Rect cropRect

The crop rectangle specifies the region of valid pixels in the buffer.

int rotationDegrees

The clockwise rotation in degrees that needs to be applied to the output buffer so the image appears upright at the target rotation setting.

Public methods

equals

public boolean equals(@Nullable Object obj)

getCropRect

Added in 1.1.0
public @NonNull Rect getCropRect()

Returns the crop rectangle.

The crop rectangle specifies the region of valid pixels in the buffer, using coordinates from (0, 0) to the (width, height) of the resolution obtained by getResolution. The dimensions need to be flipped by the rotation degrees obtained via getRotationDegrees to match the target rotation setting.

If the use case is configured with a ViewPort, this value is calculated based on the configuration of ViewPort; if not, it returns the full rect of the buffer which the dimensions will be the same as the value obtained from getResolution.

getResolution

Added in 1.1.0
public @NonNull Size getResolution()

Returns the output resolution used for the use case.

The resolution will be expressed in the coordinates of the camera sensor. The dimensions need to be flipped by the rotation degrees obtained via getRotationDegrees to match the target rotation setting.

getRotationDegrees

Added in 1.1.0
public int getRotationDegrees()

Returns the rotation degrees needed to transform the output resolution to the target rotation.

This is a clockwise rotation in degrees that needs to be applied to the output buffer so the image appears upright at the target rotation setting. The rotation will be determined by the camera sensor orientation value and target rotation setting.

Returns
int

The rotation in degrees which will be a value in {0, 90, 180, 270}.

hashCode

public int hashCode()

toString

public @NonNull String toString()