# RgbMatrix

Artifact: [androidx.media3:media3-effect](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/effect/RgbMatrix.java+class:androidx.media3.effect.RgbMatrix)

*** ** * ** ***

<br />

```
@UnstableApi
interface RgbMatrix : GlEffect
```

<br />

Known direct subclasses [Brightness](https://developer.android.com/reference/kotlin/androidx/media3/effect/Brightness), [Contrast](https://developer.android.com/reference/kotlin/androidx/media3/effect/Contrast), [RgbAdjustment](https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbAdjustment), [RgbFilter](https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbFilter)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/Brightness` | Modifies brightness of an input frame. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/Contrast` | A `https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbMatrix` to control the contrast of video frames. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbAdjustment` | Scales the red, green, and blue color channels of a frame. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbFilter` | Provides common color filters. |

*** ** * ** ***

Specifies a 4x4 RGB color transformation matrix to apply to each frame in the fragment shader.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbMatrix#getMatrix(long,boolean)(presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, useHdr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns the 4x4 RGB transformation `https://developer.android.com/reference/android/opengl/Matrix.html` to apply to the color values of each pixel in the frame with the given timestamp. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/BaseGlShaderProgram!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbMatrix#toGlShaderProgram(android.content.Context,boolean)(context: https://developer.android.com/reference/android/content/Context.html!, useHdr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram` that applies the effect. |

### Inherited functions

From [androidx.media3.common.Effect](https://developer.android.com/reference/kotlin/androidx/media3/common/Effect) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/common/Effect#getDurationAfterEffectApplied(long)(durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Returns the expected duration of the output stream when the effect is applied given a input `durationUs`.
From [androidx.media3.effect.GlEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect#isNoOp(int,int)(inputWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, inputHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Returns whether a `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect` applies no change at every timestamp.

## Public functions

### getMatrix

```
fun getMatrix(presentationTimeUs: Long, useHdr: Boolean): Array<Float>!
```

Returns the 4x4 RGB transformation `https://developer.android.com/reference/android/opengl/Matrix.html` to apply to the color values of each pixel in the frame with the given timestamp.

| Parameters |
|---|---|
| `presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The timestamp of the frame to apply the matrix on. |
| `useHdr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | If `true`, colors will be in linear RGB BT.2020. If `false`, colors will be in linear RGB BT.709. Must be consistent with `useHdr` in `https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbMatrix#toGlShaderProgram(android.content.Context,boolean)`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>!` | The `RgbMatrix` to apply to the frame. |

### toGlShaderProgram

```
fun toGlShaderProgram(context: Context!, useHdr: Boolean): BaseGlShaderProgram!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram` that applies the effect.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html!` | A `https://developer.android.com/reference/android/content/Context.html`. |
| `useHdr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether input textures come from an HDR source. If `true`, colors will be in linear RGB BT.2020. If `false`, colors will be in linear RGB BT.709. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while creating the `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram`. |