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

*** ** * ** ***


```
@UnstableApi
public final class Crop implements 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/androidx/media3/effect/Crop#Crop(float,float,float,float)(float left, float right, float bottom, float top)` 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 methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/Size` | `https://developer.android.com/reference/androidx/media3/effect/Crop#configure(int,int)(int inputWidth, int inputHeight)` Configures the input and output dimensions. |
| `https://developer.android.com/reference/android/graphics/Matrix.html` | `https://developer.android.com/reference/androidx/media3/effect/Crop#getMatrix(long)(long presentationTimeUs)` Returns the 3x3 transformation `https://developer.android.com/reference/android/graphics/Matrix.html` to apply to the frame with the given timestamp. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/effect/Crop#isNoOp(int,int)(int inputWidth, int inputHeight)` Returns whether a `https://developer.android.com/reference/androidx/media3/effect/GlEffect` applies no change at every timestamp. |

| ### Inherited methods |
|---|
| From [androidx.media3.common.Effect](https://developer.android.com/reference/androidx/media3/common/Effect) |---|---| | `long` | `https://developer.android.com/reference/androidx/media3/common/Effect#getDurationAfterEffectApplied(long)(long durationUs)` 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/androidx/media3/effect/GlEffect) |---|---| | `abstract https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` | `https://developer.android.com/reference/androidx/media3/effect/GlEffect#toGlShaderProgram(android.content.Context,boolean)(https://developer.android.com/reference/android/content/Context.html context, boolean useHdr)` Returns a `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` that applies the effect. | |
| From [androidx.media3.effect.GlMatrixTransformation](https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation) |---|---| | `int` | `@https://developer.android.com/reference/androidx/media3/common/C.TextureMinFilter https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation#getGlTextureMinFilter()()` Returns the `https://developer.android.com/reference/androidx/media3/common/C.TextureMinFilter` to use for sampling the input texture when applying this matrix transformation. | | `https://developer.android.com/reference/androidx/media3/effect/BaseGlShaderProgram` | `https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation#toGlShaderProgram(android.content.Context,boolean)(https://developer.android.com/reference/android/content/Context.html context, boolean useHdr)` Returns a `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` that applies the effect. | |
| From [androidx.media3.effect.MatrixTransformation](https://developer.android.com/reference/androidx/media3/effect/MatrixTransformation) |---|---| | `float[]` | `https://developer.android.com/reference/androidx/media3/effect/MatrixTransformation#getGlMatrixArray(long)(long presentationTimeUs)` 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

```
public Crop(float left, float right, float bottom, float top)
```

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 |
|---|---|
| `float left` | The left edge of the output frame, in NDC. Must be less than `right`. |
| `float right` | The right edge of the output frame, in NDC. Must be greater than `left`. |
| `float bottom` | The bottom edge of the output frame, in NDC. Must be less than `top`. |
| `float top` | The top edge of the output frame, in NDC. Must be greater than `bottom`. |

## Public methods

### configure

```
public Size configure(int inputWidth, int inputHeight)
```

Configures the input and output dimensions.

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

| Parameters |
|---|---|
| `int inputWidth` | The input frame width, in pixels. |
| `int inputHeight` | The input frame height, in pixels. |

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

### getMatrix

```
public Matrix getMatrix(long presentationTimeUs)
```

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

### isNoOp

```
public boolean isNoOp(int inputWidth, int inputHeight)
```

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

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

| Parameters |
|---|---|
| `int inputWidth` | The input frame width, in pixels. |
| `int inputHeight` | The input frame height, in pixels. |