# LanczosResample

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

*** ** * ** ***


```
@UnstableApi
public final class LanczosResample implements GlEffect
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/effect/GlEffect` that applies a Lanczos-windowed sinc function when resampling an image. See Filters for Common Resampling Tasks, Ken Turkowski.

The filter rescales images in both dimensions with the same scaling factor.

## Summary

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/effect/LanczosResample#isNoOp(int,int)(int inputWidth, int inputHeight)` Returns whether a applies no change at every timestamp. |
| `static https://developer.android.com/reference/androidx/media3/effect/LanczosResample` | `https://developer.android.com/reference/androidx/media3/effect/LanczosResample#scaleToFit(int,int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int width, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int height)` Creates an instance. |
| `static https://developer.android.com/reference/androidx/media3/effect/LanczosResample` | `https://developer.android.com/reference/androidx/media3/effect/LanczosResample#scaleToFitWithFlexibleOrientation(int,int)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int firstDimension, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int secondDimension )` Creates an instance. |
| `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` | `https://developer.android.com/reference/androidx/media3/effect/LanczosResample#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. |

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

## Public methods

### isNoOp

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

Returns whether a applies no change at every timestamp.

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

For scaling factors near 1, this effect applies no change because the Lanczos algorithm won't bring a big improvement over bilinear or nearest sampling using the GPU texture units.

### scaleToFit

```
public static LanczosResample scaleToFit(@IntRange(from = 1) int width, @IntRange(from = 1) int height)
```

Creates an instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int width` | The width inside which the output contents will fit. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int height` | The height inside which the output contents will fit. |

### scaleToFitWithFlexibleOrientation

```
public static LanczosResample scaleToFitWithFlexibleOrientation(
    @IntRange(from = 1) int firstDimension,
    @IntRange(from = 1) int secondDimension
)
```

Creates an instance.

The output resolution will be either `firstDimension` x `secondDimension` or `secondDimension` x `firstDimension`. The longer of `firstDimension` or `secondDimension` will have the same orientation as the longer side of the `https://developer.android.com/reference/androidx/media3/common/util/Size` passed in to `https://developer.android.com/reference/androidx/media3/effect/LanczosResample.LanczosResampleScaledFunctionProvider#configure(androidx.media3.common.util.Size)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int firstDimension` | The first dimension of the output contents. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int secondDimension` | The second dimension of the output contents. |

### toGlShaderProgram

```
public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
```

Returns a `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` that applies the effect.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | A `https://developer.android.com/reference/android/content/Context.html`. |
| `boolean useHdr` | Whether input textures come from an HDR source. If `true`, colors will be in linear RGB BT.2020. If `false`, colors will be in linear RGB BT.709. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while creating the `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram`. |