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

*** ** * ** ***


```
@UnstableApi
public final class ScaleAndRotateTransformation implements 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 |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/effect/ScaleAndRotateTransformation.Builder` A builder for `https://developer.android.com/reference/androidx/media3/effect/ScaleAndRotateTransformation` instances. |

| ### Public fields |
|---|---|
| `final float` | `https://developer.android.com/reference/androidx/media3/effect/ScaleAndRotateTransformation#rotationDegrees()` The counterclockwise rotation, in degrees. |
| `final float` | `https://developer.android.com/reference/androidx/media3/effect/ScaleAndRotateTransformation#scaleX()` The multiplier by which the frame will scale horizontally, along the x-axis. |
| `final float` | `https://developer.android.com/reference/androidx/media3/effect/ScaleAndRotateTransformation#scaleY()` The multiplier by which the frame will scale vertically, along the y-axis. |

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

### rotationDegrees

```
public final float rotationDegrees
```

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

### scaleX

```
public final float scaleX
```

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

### scaleY

```
public final float scaleY
```

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

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