# ScaleAndRotateTransformation

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

*** ** * ** ***

<br />

```
@UnstableApi
class ScaleAndRotateTransformation : MatrixTransformation
```

<br />

*** ** * ** ***

Specifies a simple rotation and/or scale to apply in the vertex shader.

All input frames' pixels will be preserved and copied into an output frame, potentially changing the width and height of the frame by scaling dimensions to fit.

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

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/effect/ScaleAndRotateTransformation.Builder` A builder for `https://developer.android.com/reference/kotlin/androidx/media3/effect/ScaleAndRotateTransformation` instances. |

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

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ScaleAndRotateTransformation#rotationDegrees()` The counterclockwise rotation, in degrees. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ScaleAndRotateTransformation#scaleX()` The multiplier by which the frame will scale horizontally, along the x-axis. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/ScaleAndRotateTransformation#scaleY()` The multiplier by which the frame will scale vertically, along the y-axis. |

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

## Public properties

### rotationDegrees

```
val rotationDegrees: Float
```

The counterclockwise rotation, in degrees. The value should always be between 0 (included) and 360 degrees (excluded).

### scaleX

```
val scaleX: Float
```

The multiplier by which the frame will scale horizontally, along the x-axis.

### scaleY

```
val scaleY: Float
```

The multiplier by which the frame will scale vertically, along the y-axis.