# Crop

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

*** ** * ** ***

<br />

```
@UnstableApi
class Crop : MatrixTransformation
```

<br />

*** ** * ** ***

Specifies a crop to apply in the vertex shader.

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/Crop#Crop(float,float,float,float)(left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Crops a smaller (or larger) frame, per normalized device coordinates (NDC), where the input frame corresponds to the square ranging from -1 to 1 on the x and y axes. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Size!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Crop#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/android/graphics/Matrix.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/Crop#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/Crop#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://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.
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.

## Public constructors

### Crop

```
Crop(left: Float, right: Float, bottom: Float, top: Float)
```

Crops a smaller (or larger) frame, per normalized device coordinates (NDC), where the input frame corresponds to the square ranging from -1 to 1 on the x and y axes.

`left` and `bottom` default to -1, and `right` and `top` default to 1, which corresponds to not applying any crop. To crop to a smaller subset of the input frame, use values between -1 and 1. To crop to a larger frame, use values below -1 and above 1.

| Parameters |
|---|---|
| `left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The left edge of the output frame, in NDC. Must be less than `right`. |
| `right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The right edge of the output frame, in NDC. Must be greater than `left`. |
| `bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The bottom edge of the output frame, in NDC. Must be less than `top`. |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The top edge of the output frame, in NDC. Must be greater than `bottom`. |

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

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