ResolutionStrategy


class ResolutionStrategy


The resolution strategy defines the resolution selection sequence to select the best size.

Applications can create a ResolutionSelector with a proper ResolutionStrategy to choose the preferred resolution.

Summary

Constants

const Int

When the specified bound size is unavailable, CameraX falls back to the closest higher resolution size.

const Int

When the specified bound size is unavailable, CameraX falls back to select the closest higher resolution size.

const Int

When the specified bound size is unavailable, CameraX falls back to the closest lower resolution size.

const Int

When the specified bound size is unavailable, CameraX falls back to select the closest lower resolution size.

const Int

CameraX doesn't select an alternate size when the specified bound size is unavailable.

const ResolutionStrategy

A resolution strategy chooses the highest available resolution.

Public constructors

ResolutionStrategy(boundSize: Size, fallbackRule: Int)

Creates a new ResolutionStrategy instance, configured with the specified bound size and fallback rule.

Public functions

Size?

Returns the specified bound size.

Int

Returns the fallback rule for choosing an alternate size when the specified bound size is unavailable.

Constants

FALLBACK_RULE_CLOSEST_HIGHER

Added in 1.3.0
const val FALLBACK_RULE_CLOSEST_HIGHER = 2: Int

When the specified bound size is unavailable, CameraX falls back to the closest higher resolution size.

FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER

Added in 1.3.0
const val FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER = 1: Int

When the specified bound size is unavailable, CameraX falls back to select the closest higher resolution size. If CameraX still cannot find any available resolution, it will fallback to select other lower resolutions.

FALLBACK_RULE_CLOSEST_LOWER

Added in 1.3.0
const val FALLBACK_RULE_CLOSEST_LOWER = 4: Int

When the specified bound size is unavailable, CameraX falls back to the closest lower resolution size.

FALLBACK_RULE_CLOSEST_LOWER_THEN_HIGHER

Added in 1.3.0
const val FALLBACK_RULE_CLOSEST_LOWER_THEN_HIGHER = 3: Int

When the specified bound size is unavailable, CameraX falls back to select the closest lower resolution size. If CameraX still cannot find any available resolution, it will fallback to select other higher resolutions.

FALLBACK_RULE_NONE

Added in 1.3.0
const val FALLBACK_RULE_NONE = 0: Int

CameraX doesn't select an alternate size when the specified bound size is unavailable.

Applications will receive IllegalArgumentException when binding the UseCases with this fallback rule if the device doesn't support the specified bound size.

HIGHEST_AVAILABLE_STRATEGY

Added in 1.3.0
const val HIGHEST_AVAILABLE_STRATEGYResolutionStrategy

A resolution strategy chooses the highest available resolution. This strategy does not have a bound size or fallback rule. When using this strategy, CameraX selects the available resolutions to use in descending order, starting with the highest quality resolution available.

Public constructors

ResolutionStrategy

Added in 1.3.0
ResolutionStrategy(boundSize: Size, fallbackRule: Int)

Creates a new ResolutionStrategy instance, configured with the specified bound size and fallback rule.

If the resolution candidate list contains the bound size and the bound size can fulfill all resolution selector settings, CameraX can also select the specified bound size as the result for the UseCase.

Some devices may have issues using sizes of the preferred aspect ratios. CameraX recommends that applications use the following fallback rule setting to avoid no resolution being available, as an IllegalArgumentException may be thrown when calling bindToLifecycle to bind UseCases with the ResolutionStrategy specified in the ResolutionSelector.

Parameters
boundSize: Size

the bound size to select the best resolution with the fallback rule.

fallbackRule: Int

the rule to follow when the specified bound size is not available.

Public functions

getBoundSize

Added in 1.3.0
fun getBoundSize(): Size?

Returns the specified bound size.

Returns
Size?

the specified bound size or null if this is instance of HIGHEST_AVAILABLE_STRATEGY.

getFallbackRule

Added in 1.3.0
fun getFallbackRule(): Int

Returns the fallback rule for choosing an alternate size when the specified bound size is unavailable.