java.lang.Object | |
↳ | android.hardware.camera2.params.MeteringRectangle |
An immutable class to represent a rectangle (x, y, width, height)
with an additional
weight component.
The rectangle is defined to be inclusive of the specified coordinates.
When used with a CaptureRequest
, the coordinate system is based on the active pixel
array, with (0,0)
being the top-left pixel in the
active pixel array
, and
(android.sensor.info.activeArraySize.width - 1,
android.sensor.info.activeArraySize.height - 1)
being the bottom-right pixel in the active pixel
array.
The weight must range from .METERING_WEIGHT_MIN
to .METERING_WEIGHT_MAX
inclusively, and represents a weight for every pixel in the area. This means that a large
metering area with the same weight as a smaller area will have more effect in the metering
result. Metering areas can partially overlap and the camera device will add the weights in the
overlap rectangle.
If all rectangles have 0 weight, then no specific metering area needs to be used by the camera device. If the metering rectangle is outside the used android.scaler.cropRegion returned in capture result metadata, the camera device will ignore the sections outside the rectangle and output the used sections in the result metadata.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | METERING_WEIGHT_DONT_CARE | Weights set to this value will cause the camera device to ignore this rectangle. | |||||||||
int | METERING_WEIGHT_MAX | The maximum value of valid metering weight. | |||||||||
int | METERING_WEIGHT_MIN | The minimum value of valid metering weight. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new metering rectangle.
| |||||||||||
Create a new metering rectangle.
| |||||||||||
Create a new metering rectangle.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compare two metering rectangles to see if they are equal.
| |||||||||||
Compares this instance with the specified object and indicates if they
are equal.
| |||||||||||
Return the height of the rectangle.
| |||||||||||
Return the metering weight of the rectangle.
| |||||||||||
Convenience method to create a
Rect from this metering rectangle.
| |||||||||||
Convenience method to create the size from this metering rectangle.
| |||||||||||
Convenience method to create the upper-left (X,Y) coordinate as a
Point .
| |||||||||||
Return the width of the rectangle.
| |||||||||||
Return the X coordinate of the left side of the rectangle.
| |||||||||||
Return the Y coordinate of the upper side of the rectangle.
| |||||||||||
Returns an integer hash code for this object.
| |||||||||||
Return the metering rectangle as a string representation
"(x:%d, y:%d, w:%d, h:%d, wt:%d)" where each %d respectively represents
the x, y, width, height, and weight points.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Weights set to this value will cause the camera device to ignore this rectangle. If all metering rectangles are weighed with 0, the camera device will choose its own metering rectangles.
The maximum value of valid metering weight.
The minimum value of valid metering weight.
Create a new metering rectangle.
x | coordinate >= 0 |
---|---|
y | coordinate >= 0 |
width | width >= 0 |
height | height >= 0 |
meteringWeight | weight between .METERING_WEIGHT_MIN and
.METERING_WEIGHT_MAX inclusively |
IllegalArgumentException | if any of the parameters were negative |
---|
Create a new metering rectangle.
The point xy
's data is copied; the reference is not retained.
xy | a non-null Point with both x,y >= 0 |
---|---|
dimensions | a non-null Size with width, height >= 0 |
meteringWeight | weight >= 0 |
IllegalArgumentException | if any of the parameters were negative |
---|---|
NullPointerException | if any of the arguments were null |
Create a new metering rectangle.
The rectangle data is copied; the reference is not retained.
rect | a non-null rectangle with all x,y,w,h dimensions >= 0 |
---|---|
meteringWeight | weight >= 0 |
IllegalArgumentException | if any of the parameters were negative |
---|---|
NullPointerException | if any of the arguments were null |
Compare two metering rectangles to see if they are equal. Two weighted rectangles are only considered equal if each of their components (x, y, width, height, weight) is respectively equal.
other | Another MeteringRectangle |
---|
true
if the metering rectangles are equal, false
otherwise
Compares this instance with the specified object and indicates if they
are equal. In order to be equal, o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
other | the object to compare this instance with. |
---|
true
if the specified object is equal to this Object
; false
otherwise.Return the height of the rectangle.
Return the metering weight of the rectangle.
Convenience method to create the size from this metering rectangle.
This strips away the X,Y,weight from the rectangle.
Size
with non-negative width and height
Return the X coordinate of the left side of the rectangle.
Return the Y coordinate of the upper side of the rectangle.
Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
Return the metering rectangle as a string representation
"(x:%d, y:%d, w:%d, h:%d, wt:%d)"
where each %d
respectively represents
the x, y, width, height, and weight points.