# Contrast

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/Contrast.java+class:androidx.media3.effect.Contrast)

*** ** * ** ***

<br />

```
@UnstableApi
class Contrast : RgbMatrix
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbMatrix` to control the contrast of video frames.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/Contrast#Contrast(float)(contrast: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = "-1", to = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Creates a new instance for the given contrast value. |

| ### 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/Contrast#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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Contrast#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. |

### 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) `abstract https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram!` `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect#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.
From [androidx.media3.effect.RgbMatrix](https://developer.android.com/reference/kotlin/androidx/media3/effect/RgbMatrix) `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.

## Public constructors

### Contrast

```
Contrast(contrast: @FloatRange(from = "-1", to = 1) Float)
```

Creates a new instance for the given contrast value.

Contrast values range from -1 (all gray pixels) to 1 (maximum difference of colors). 0 means to add no contrast and leaves the frames unchanged.

## 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. |

### isNoOp

```
fun isNoOp(inputWidth: Int, inputHeight: Int): Boolean
```

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

This can be used as a hint to skip this instance.

| Parameters |
|---|---|
| `inputWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The input frame width, in pixels. |
| `inputHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The input frame height, in pixels. |