Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#pubctors) \| [Methods](https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#inhmethods)

# ColorSpaceTransform

*** ** * ** ***


`
public

final

class
ColorSpaceTransform
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.hardware.camera2.params.ColorSpaceTransform |

<br />

*** ** * ** ***

Immutable class for describing a 3x3 matrix of `https://developer.android.com/reference/android/util/Rational` values in row-major order.

This matrix maps a transform from one color space to another. For the particular color space
source and target, see the appropriate camera metadata documentation for the key that provides
this value.

<br />

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/CameraMetadata`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#ColorSpaceTransform(android.util.Rational[])(https://developer.android.com/reference/android/util/Rational elements) ` Create a new immutable `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform` instance from a `https://developer.android.com/reference/android/util/Rational` array. |
| ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#ColorSpaceTransform(int[])(int[] elements) ` Create a new immutable `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform` instance from an `int` array. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#copyElements(int[],%20int)(int[] destination, int offset) ` Copy the `https://developer.android.com/reference/android/util/Rational` elements in row-major order from this matrix into the destination. |
| ` void` | ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#copyElements(android.util.Rational[],%20int)(https://developer.android.com/reference/android/util/Rational destination, int offset) ` Copy the `https://developer.android.com/reference/android/util/Rational` elements in row-major order from this matrix into the destination. |
| ` boolean` | ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Check if this `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform` is equal to another `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform`. |
| ` https://developer.android.com/reference/android/util/Rational` | ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#getElement(int,%20int)(int column, int row) ` Get an element of this matrix by its row and column. |
| ` int` | ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#hashCode()() ` Returns a hash code value for the object. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#toString()() ` Return the color space transform as a string representation. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### ColorSpaceTransform

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ColorSpaceTransform (Rational[] elements)
```

Create a new immutable `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform` instance from a `https://developer.android.com/reference/android/util/Rational` array.

The elements must be stored in a row-major order.

<br />

<br />

| Parameters ||
|---|---|
| `elements` | `Rational`: An array of `9` elements <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the count of `elements` is not `9` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `elements` or any sub-element is `null` |

### ColorSpaceTransform

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ColorSpaceTransform (int[] elements)
```

Create a new immutable `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform` instance from an `int` array.

The elements must be stored in a row-major order. Each rational is stored
contiguously as a `(numerator, denominator)` pair.

In particular:

    int[] elements = new int[
        N11, D11, N12, D12, N13, D13,
        N21, D21, N22, D22, N23, D23,
        N31, D31, N32, D32, N33, D33
    ];

    new ColorSpaceTransform(elements)

where `Nij` and `Dij` is the numerator and denominator for row `i` and column `j`.

<br />

<br />

<br />

| Parameters ||
|---|---|
| `elements` | `int`: An array of `18` elements <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the count of `elements` is not `18` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `elements` is `null` |

## Public methods

### copyElements

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void copyElements (int[] destination, 
                int offset)
```

Copy the `https://developer.android.com/reference/android/util/Rational` elements in row-major order from this matrix into the destination.

Each element is stored as a contiguous rational packed as a
`(numerator, denominator)` pair of ints, identical to the
`https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#ColorSpaceTransform(int[])`.

<br />

<br />

| Parameters ||
|---|---|
| `destination` | `int`: an array big enough to hold at least `18` elements after the `offset` <br /> |
| `offset` | `int`: a non-negative offset into the array <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` | If there's not enough room to write the elements at the specified destination and offset. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `destination` was `null` |

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform#ColorSpaceTransform(int[])`

### copyElements

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void copyElements (Rational[] destination, 
                int offset)
```

Copy the `https://developer.android.com/reference/android/util/Rational` elements in row-major order from this matrix into the destination.

<br />

| Parameters ||
|---|---|
| `destination` | `Rational`: an array big enough to hold at least `9` elements after the `offset` <br /> |
| `offset` | `int`: a non-negative offset into the array <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` | If there's not enough room to write the elements at the specified destination and offset. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `destination` was `null` |

### equals

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object obj)
```

Check if this `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform` is equal to another `https://developer.android.com/reference/android/hardware/camera2/params/ColorSpaceTransform`.

Two color space transforms are equal if and only if all of their elements are
`https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)`.

<br />

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the objects were equal, `false` otherwise <br /> |

### getElement

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Rational getElement (int column, 
                int row)
```

Get an element of this matrix by its row and column.

The rows must be within the range \[0, 3),
and the column must be within the range \[0, 3).

<br />

<br />

| Parameters ||
|---|---|
| `column` | `int` <br /> |
| `row` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/util/Rational` | element (non-`null`) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if column or row was out of range |

### hashCode

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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
`https://developer.android.com/reference/java/util/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 `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` 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 `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` 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.

<br />

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### toString

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Return the color space transform as a string representation.

Example:
`"ColorSpaceTransform([1/1, 0/1, 0/1], [0/1, 1/1, 0/1], [0/1, 0/1, 1/1])"` is an
identity transform. Elements are printed in row major order.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | string representation of color space transform <br /> |