# ColorConversion

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

*** ** * ** ***


```
@ExperimentalApi
class ColorConversion : GlEffect
```

<br />

*** ** * ** ***

Converts frames from an input color space to an electrical output color space.

Applying this effect last in an effect chain sets the output color space of the video frame processing pipeline.

## Summary

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/effect/ColorConversion!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ColorConversion#create(androidx.media3.common.ColorInfo)(outputColorInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo!)` Creates an instance that converts frames to `outputColorInfo`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ColorConversion#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)` Not supported, because the input color space is only known once the pipeline receives frames. |

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

### create

```
java-static fun create(outputColorInfo: ColorInfo!): ColorConversion!
```

Creates an instance that converts frames to `outputColorInfo`.

Supported outputs are BT.2020 with `https://developer.android.com/reference/kotlin/androidx/media3/common/C#COLOR_TRANSFER_HLG()`, and BT.709 with `https://developer.android.com/reference/kotlin/androidx/media3/common/C#COLOR_TRANSFER_SRGB()`. Other properties of `outputColorInfo`, such as the `https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo#colorRange()`, do not affect the conversion and are propagated to the output frames unchanged.

| Parameters |
|---|---|
| `outputColorInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/ColorInfo` to convert frames to. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/ColorConversion!` | A new instance. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `outputColorInfo` is not supported. |

### toGlShaderProgram

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

Not supported, because the input color space is only known once the pipeline receives frames.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | Always. This effect is only supported by `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlFrameProcessor`. |