@UnstableApi
class Crop : MatrixTransformation


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

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.

Public functions

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

Configures the input and output dimensions.

Matrix!
getMatrix(presentationTimeUs: Long)

Returns the 3x3 transformation Matrix to apply to the frame with the given timestamp.

Boolean
isNoOp(inputWidth: Int, inputHeight: Int)

Returns whether a GlEffect applies no change at every timestamp.

Inherited functions

From androidx.media3.common.Effect
Long

Returns the expected duration of the output stream when the effect is applied given a input durationUs.

From androidx.media3.effect.GlEffect
abstract GlShaderProgram!
toGlShaderProgram(context: Context!, useHdr: Boolean)

Returns a GlShaderProgram that applies the effect.

From androidx.media3.effect.GlMatrixTransformation
BaseGlShaderProgram!
toGlShaderProgram(context: Context!, useHdr: Boolean)

Returns a GlShaderProgram that applies the effect.

From androidx.media3.effect.MatrixTransformation
FloatArray<Float>!
getGlMatrixArray(presentationTimeUs: Long)

Returns the 4x4 transformation Matrix 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: Float

The left edge of the output frame, in NDC. Must be less than right.

right: Float

The right edge of the output frame, in NDC. Must be greater than left.

bottom: Float

The bottom edge of the output frame, in NDC. Must be less than top.

top: Float

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

Parameters
inputWidth: Int

The input frame width, in pixels.

inputHeight: Int

The input frame height, in pixels.

Returns
Size!

The output frame width and height, in pixels.

getMatrix

fun getMatrix(presentationTimeUs: Long): Matrix!

Returns the 3x3 transformation Matrix to apply to the frame with the given timestamp.

isNoOp

fun isNoOp(inputWidth: Int, inputHeight: Int): Boolean

Returns whether a GlEffect applies no change at every timestamp.

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

Parameters
inputWidth: Int

The input frame width, in pixels.

inputHeight: Int

The input frame height, in pixels.