# Presentation

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

*** ** * ** ***

<br />

```
@UnstableApi
class Presentation : MatrixTransformation
```

<br />

*** ** * ** ***

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

The background color of the output frame will be black, with alpha = 0 if applicable.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation.Layout` Strategies controlling the layout of input pixels in the output frame. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#LAYOUT_SCALE_TO_FIT() = 0` Empty pixels added above and below the input frame (for letterboxing), or to the left and right of the input frame (for pillarboxing), until the desired aspect ratio is achieved. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#LAYOUT_SCALE_TO_FIT_WITH_CROP() = 1` Pixels cropped from the input frame, until the desired aspect ratio is achieved. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#LAYOUT_STRETCH_TO_FIT() = 2` Frame stretched larger on the x or y axes to fit the desired aspect ratio. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Size!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#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://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#copyWithTextureMinFilter(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.TextureMinFilter textureMinFilter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a copy with the specified texture minification filter. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#copyWithUnsetSideRoundedTo(int)(divisor: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a copy that will round the unset side length to the given `divisor`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#createForAspectRatio(float,int)( aspectRatio: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, @https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation.Layout layout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#createForHeight(int)(height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#createForShortSide(int)(shortSide: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#createForWidthAndHeight(int,int,int)( width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, @https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation.Layout layout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance. |
| `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/Presentation#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/android/graphics/Matrix.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#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.GlMatrixTransformation](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlMatrixTransformation) `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.
From [androidx.media3.effect.MatrixTransformation](https://developer.android.com/reference/kotlin/androidx/media3/effect/MatrixTransformation) `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.

## Constants

### LAYOUT_SCALE_TO_FIT

```
const val LAYOUT_SCALE_TO_FIT = 0: Int
```

Empty pixels added above and below the input frame (for letterboxing), or to the left and right of the input frame (for pillarboxing), until the desired aspect ratio is achieved. All input frame pixels will be within the output frame.

When applying:

- letterboxing, the output width will default to the input width, and the output height will be scaled appropriately.
- pillarboxing, the output height will default to the input height, and the output width will be scaled appropriately.

### LAYOUT_SCALE_TO_FIT_WITH_CROP

```
const val LAYOUT_SCALE_TO_FIT_WITH_CROP = 1: Int
```

Pixels cropped from the input frame, until the desired aspect ratio is achieved. Pixels may be cropped either from the bottom and top, or from the left and right sides, of the input frame.

When cropping from the:

- bottom and top, the output width will default to the input width, and the output height will be scaled appropriately.
- left and right, the output height will default to the input height, and the output width will be scaled appropriately.

### LAYOUT_STRETCH_TO_FIT

```
const val LAYOUT_STRETCH_TO_FIT = 2: Int
```

Frame stretched larger on the x or y axes to fit the desired aspect ratio.

When stretching to a:

- taller aspect ratio, the output width will default to the input width, and the output height will be scaled appropriately.
- narrower aspect ratio, the output height will default to the input height, and the output width will be scaled appropriately.

## Public functions

### configure

```
fun configure(inputWidth: Int, inputHeight: Int): Size!
```

Configures the input and output dimensions.

Must be called before `https://developer.android.com/reference/kotlin/androidx/media3/effect/GlMatrixTransformation#getGlMatrixArray(long)`.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Size!` | The output frame width and height, in pixels. |

### copyWithTextureMinFilter

```
fun copyWithTextureMinFilter(@C.TextureMinFilter textureMinFilter: Int): Presentation!
```

Returns a copy with the specified texture minification filter.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.TextureMinFilter textureMinFilter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TextureMinFilter`. |

### copyWithUnsetSideRoundedTo

```
fun copyWithUnsetSideRoundedTo(divisor: Int): Presentation!
```

Returns a copy that will round the unset side length to the given `divisor`.

| Parameters |
|---|---|
| `divisor: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The value to round the unset side length to. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | When the copied `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` has `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#createForWidthAndHeight(int,int,int)`, or `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation#createForAspectRatio(float,int)`. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | When the divisor is less than 1. |

### createForAspectRatio

```
java-static fun createForAspectRatio(
    aspectRatio: @FloatRange(from = 0, fromInclusive = false) Float,
    @Presentation.Layout layout: Int
): Presentation!
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance.

The output frame will have the given aspect ratio (width/height ratio). Width or height will be resized to conform to this `aspectRatio`, given a `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation.Layout`.

| Parameters |
|---|---|
| `aspectRatio: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The aspect ratio (width/height ratio) of the output frame. Must be positive. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation.Layout layout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The layout of the output frame. |

### createForHeight

```
java-static fun createForHeight(height: Int): Presentation!
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance.

The output frame will have the given height. Width will scale to preserve the input aspect ratio. For example, a 1920x1440 video can be scaled to 640x480 by passing a height of 480.

| Parameters |
|---|---|
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The height of the output frame, in pixels. |

### createForShortSide

```
java-static fun createForShortSide(shortSide: Int): Presentation!
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance.

The output frame will have a short side matching the given value. The longest side will scale to preserve the input aspect \* ratio. For example, passing a shortSide of 480 will scale a 1440x1920 video to 480x640 or a 1920x1440 video to 640x480.

| Parameters |
|---|---|
| `shortSide: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the short side of the output frame, in pixels. |

### createForWidthAndHeight

```
java-static fun createForWidthAndHeight(
    width: Int,
    height: Int,
    @Presentation.Layout layout: Int
): Presentation!
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation` instance.

The output frame will have the given width and height, given a `https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation.Layout`.

Width and height must be positive integers representing the output frame's width and height.

| Parameters |
|---|---|
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The width of the output frame, in pixels. |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The height of the output frame, in pixels. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/effect/Presentation.Layout layout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The layout of the output frame. |

### getGlTextureMinFilter

```
@C.TextureMinFilter
fun getGlTextureMinFilter(): Int
```

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.

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

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