TonemapCurve


public final class TonemapCurve
extends Object

java.lang.Object
   ↳ android.hardware.camera2.params.TonemapCurve


Immutable class for describing a 2 x M x 3 tonemap curve of floats.

This defines red, green, and blue curves that the CameraDevice will use as the tonemapping/contrast/gamma curve when CaptureRequest.TONEMAP_MODE is set to CameraMetadata.TONEMAP_MODE_CONTRAST_CURVE.

For a camera device with MONOCHROME capability, all 3 channels will contain the same set of control points.

The total number of points (Pin, Pout) for each color channel can be no more than CameraCharacteristics.TONEMAP_MAX_CURVE_POINTS.

The coordinate system for each point is within the inclusive range [.LEVEL_BLACK, .LEVEL_WHITE].

Summary

Constants

int CHANNEL_BLUE

Index of the blue color channel curve.

int CHANNEL_GREEN

Index of the green color channel curve.

int CHANNEL_RED

Index of the red color channel curve.

float LEVEL_BLACK

Lower bound tonemap value corresponding to pure black for a single color channel.

float LEVEL_WHITE

Upper bound tonemap value corresponding to a pure white for a single color channel.

int POINT_SIZE

Number of elements in a (Pin, Pout) point;

Public constructors

TonemapCurve(float[] red, float[] green, float[] blue)

Create a new immutable TonemapCurve instance.

Public methods

void copyColorCurve(int colorChannel, float[] destination, int offset)

Copy the color curve for a single color channel from this tonemap curve into the destination.

boolean equals(Object obj)

Check if this TonemapCurve is equal to another TonemapCurve.

PointF getPoint(int colorChannel, int index)

Get the point for a color channel at a specified index.

int getPointCount(int colorChannel)

Get the number of points stored in this tonemap curve for the specified color channel.

int hashCode()

Returns a hash code value for the object.

String toString()

Return the TonemapCurve as a string representation.

Inherited methods

Constants

CHANNEL_BLUE

Added in API level 21
public static final int CHANNEL_BLUE

Index of the blue color channel curve.

Constant Value: 2 (0x00000002)

CHANNEL_GREEN

Added in API level 21
public static final int CHANNEL_GREEN

Index of the green color channel curve.

Constant Value: 1 (0x00000001)

CHANNEL_RED

Added in API level 21
public static final int CHANNEL_RED

Index of the red color channel curve.

Constant Value: 0 (0x00000000)

LEVEL_BLACK

Added in API level 21
public static final float LEVEL_BLACK

Lower bound tonemap value corresponding to pure black for a single color channel.

Constant Value: 0.0

LEVEL_WHITE

Added in API level 21
public static final float LEVEL_WHITE

Upper bound tonemap value corresponding to a pure white for a single color channel.

Constant Value: 1.0

POINT_SIZE

Added in API level 21
public static final int POINT_SIZE

Number of elements in a (Pin, Pout) point;

Constant Value: 2 (0x00000002)

Public constructors

TonemapCurve

Added in API level 21
public TonemapCurve (float[] red, 
                float[] green, 
                float[] blue)

Create a new immutable TonemapCurve instance.

Values are stored as a contiguous array of (Pin, Pout) points.

All parameters may have independent length but should have at most CameraCharacteristics.TONEMAP_MAX_CURVE_POINTS * .POINT_SIZE elements and at least 2 * .POINT_SIZE elements.

All sub-elements must be in the inclusive range of [.LEVEL_BLACK, .LEVEL_WHITE].

This constructor copies the array contents and does not retain ownership of the array.

Parameters
red float: An array of elements whose length is divisible by .POINT_SIZE

green float: An array of elements whose length is divisible by .POINT_SIZE

blue float: An array of elements whose length is divisible by .POINT_SIZE

Throws
IllegalArgumentException if any of input array length is invalid, or if any of the elements in the array are not in the range of [.LEVEL_BLACK, .LEVEL_WHITE]
NullPointerException if any of the parameters are null

Public methods

copyColorCurve

Added in API level 21
public void copyColorCurve (int colorChannel, 
                float[] destination, 
                int offset)

Copy the color curve for a single color channel from this tonemap curve into the destination.

Values are stored as packed (Pin, Pout) points, and there are a total of getPointCount(int) points for that respective channel.

All returned coordinates are between the range of [.LEVEL_BLACK, .LEVEL_WHITE].

Parameters
colorChannel int

destination float: an array big enough to hold at least getPointCount(int) * POINT_SIZE elements after the offset

offset int: a non-negative offset into the array

Throws
NullPointerException If destination was null
IllegalArgumentException If offset was negative
ArrayIndexOutOfBoundsException If there's not enough room to write the elements at the specified destination and offset.

equals

Added in API level 21
public boolean equals (Object obj)

Check if this TonemapCurve is equal to another TonemapCurve.

Two matrices are equal if and only if all of their elements are equal.

Parameters
obj Object: This value may be null.

Returns
boolean true if the objects were equal, false otherwise

getPoint

Added in API level 21
public PointF getPoint (int colorChannel, 
                int index)

Get the point for a color channel at a specified index.

The index must be at least 0 but no greater than getPointCount(int) for that colorChannel.

All returned coordinates in the point are between the range of [.LEVEL_BLACK, .LEVEL_WHITE].

Parameters
colorChannel int: CHANNEL_RED, CHANNEL_GREEN, or CHANNEL_BLUE

index int: at least 0 but no greater than getPointCount(colorChannel)

Returns
PointF the (Pin, Pout) pair mapping the tone for that index

Throws
IllegalArgumentException if colorChannel or index was out of range

getPointCount

Added in API level 21
public int getPointCount (int colorChannel)

Get the number of points stored in this tonemap curve for the specified color channel.

Parameters
colorChannel int: one of CHANNEL_RED, CHANNEL_GREEN, CHANNEL_BLUE

Returns
int number of points stored in this tonemap for that color's curve (>= 0)

Throws
IllegalArgumentException if colorChannel was out of range

hashCode

Added in API level 21
public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Returns
int a hash code value for this object.

toString

Added in API level 21
public String toString ()

Return the TonemapCurve as a string representation.

"TonemapCurve{R:[(%f, %f), (%f, %f) ... (%f, %f)], G:[(%f, %f), (%f, %f) ... (%f, %f)], B:[(%f, %f), (%f, %f) ... (%f, %f)]}", where each (%f, %f) respectively represents one point of the corresponding tonemap curve.

Returns
String string representation of TonemapCurve