public class ParamsUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
convertRectF(Rect source,
RectF destination)
Convert an integral rectangle (
source ) to a floating point rectangle
(destination ) in-place. |
static Rational |
createRational(float value)
Create a
Rational value by approximating the float value as a rational. |
static Rect |
createRect(RectF rect)
Create a
Rect from a RectF by creating a new rectangle with
each corner (left, top, right, bottom) rounded towards the nearest integer bounding box. |
static Rect |
createRect(Size size)
Create a
Rect from a Size by creating a new rectangle with
left, top = (0, 0) and right, bottom = (width, height) |
static Size |
createSize(Rect rect)
Create a
Size from a Rect by creating a new size whose width
and height are the same as the rectangle's width and heights. |
static <T> T |
getOrDefault(CaptureRequest r,
CaptureRequest.Key<T> key,
T defaultValue)
Return the value set by the key, or the
defaultValue if no value was set. |
static Rect |
mapRect(Matrix transform,
Rect rect)
Map the rectangle in
rect with the transform in transform into
a new rectangle, with each corner (left, top, right, bottom) rounded towards the nearest
integer bounding box. |
public static Rect createRect(Size size)
Rect
from a Size
by creating a new rectangle with
left, top = (0, 0)
and right, bottom = (width, height)
size
- a non-null
sizenon-null
rectangleNullPointerException
- if size
was null
public static Rect createRect(RectF rect)
Rect
from a RectF
by creating a new rectangle with
each corner (left, top, right, bottom) rounded towards the nearest integer bounding box.
In particular (left, top) is floored, and (right, bottom) is ceiled.
size
- a non-null
rectnon-null
rectangleNullPointerException
- if rect
was null
public static Rect mapRect(Matrix transform, Rect rect)
rect
with the transform in transform
into
a new rectangle, with each corner (left, top, right, bottom) rounded towards the nearest
integer bounding box.
None of the arguments are mutated.
transform
- a non-null
transformation matrixrect
- a non-null
rectangletransform
NullPointerException
- if any of the args were null
public static Size createSize(Rect rect)
Size
from a Rect
by creating a new size whose width
and height are the same as the rectangle's width and heights.rect
- a non-null
rectanglenon-null
sizeNullPointerException
- if rect
was null
public static Rational createRational(float value)
Rational
value by approximating the float value as a rational.
Floating points too large to be represented as an integer will be converted to
to Integer.MAX_VALUE
; floating points too small to be represented as an integer
will be converted to Integer.MIN_VALUE
.
value
- a floating point valuepublic static void convertRectF(Rect source, RectF destination)
source
) to a floating point rectangle
(destination
) in-place.source
- the originating integer rectangle will be read from heredestination
- the resulting floating point rectangle will be written out to hereNullPointerException
- if rect
was null
public static <T> T getOrDefault(CaptureRequest r, CaptureRequest.Key<T> key, T defaultValue)
defaultValue
if no value was set.NullPointerException
- if any of the args were null