# MatrixTransformation

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

*** ** * ** ***

<br />

```
@UnstableApi
interface MatrixTransformation : GlMatrixTransformation
```

<br />

Known direct subclasses [Crop](https://developer.android.com/reference/kotlin/androidx/media3/effect/Crop), [Presentation](https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation), [ScaleAndRotateTransformation](https://developer.android.com/reference/kotlin/androidx/media3/effect/ScaleAndRotateTransformation)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/Crop` | Specifies a crop to apply in the vertex shader. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` | Controls how a frame is presented with options to set the output resolution and choose how to map the input pixels onto the output frame geometry (for example, by stretching the input frame to match the specified output frame, or fitting the input frame using letterboxing). |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/ScaleAndRotateTransformation` | Specifies a simple rotation and/or scale to apply in the vertex shader. |

*** ** * ** ***

Specifies a 3x3 transformation `https://developer.android.com/reference/android/graphics/Matrix.html` to apply in the vertex shader for each frame.

The matrix is applied to points given in normalized device coordinates (-1 to 1 on x and y axes). Transformed pixels that are moved outside of the normal device coordinate range are clipped.

Output frame pixels outside of the transformed input frame will be black, with alpha = 0 if applicable.

## 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/MatrixTransformation#getGlMatrixArray(long)(presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the 4x4 transformation `https://developer.android.com/reference/android/opengl/Matrix.html` to apply to the frame with the given timestamp. |
| `https://developer.android.com/reference/android/graphics/Matrix.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/MatrixTransformation#getMatrix(long)(presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the 3x3 transformation `https://developer.android.com/reference/android/graphics/Matrix.html` to apply to the frame with the given 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) `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.
`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.GlMatrixTransformation](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlMatrixTransformation) `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Size!` `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlMatrixTransformation#configure(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)`

Configures the input and output dimensions.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.TextureMinFilter
https://developer.android.com/reference/kotlin/androidx/media3/effect/GlMatrixTransformation#getGlTextureMinFilter()()`

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TextureMinFilter` to use for sampling the input texture when applying this matrix transformation.
`https://developer.android.com/reference/kotlin/androidx/media3/effect/BaseGlShaderProgram!` `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlMatrixTransformation#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 functions

### getGlMatrixArray

```
fun getGlMatrixArray(presentationTimeUs: Long): Array<Float>!
```

Returns the 4x4 transformation `https://developer.android.com/reference/android/opengl/Matrix.html` to apply to the frame with the given timestamp.

### getMatrix

```
fun getMatrix(presentationTimeUs: Long): Matrix!
```

Returns the 3x3 transformation `https://developer.android.com/reference/android/graphics/Matrix.html` to apply to the frame with the given timestamp.