# LanczosResample

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/effect/LanczosResample "View this page in Java")

<br />

```
@UnstableApi
class LanczosResample : GlEffect
```

<br />

*** ** * ** ***

A[GlEffect](https://developer.android.com/reference/kotlin/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 functions                                                    |
|---------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                       | [isNoOp](https://developer.android.com/reference/kotlin/androidx/media3/effect/LanczosResample#isNoOp(int,int))`(inputWidth: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, inputHeight: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns whether a applies no change at every timestamp.                                                                                                                                                                                                                                              |
| `java-static `[LanczosResample](https://developer.android.com/reference/kotlin/androidx/media3/effect/LanczosResample)`!` | [scaleToFit](https://developer.android.com/reference/kotlin/androidx/media3/effect/LanczosResample#scaleToFit(int,int))`(width: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, height: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Creates an instance.                                                                         |
| `java-static `[LanczosResample](https://developer.android.com/reference/kotlin/androidx/media3/effect/LanczosResample)`!` | [scaleToFitWithFlexibleOrientation](https://developer.android.com/reference/kotlin/androidx/media3/effect/LanczosResample#scaleToFitWithFlexibleOrientation(int,int))`(` ` firstDimension: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` secondDimension: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Creates an instance. |
| [GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)`!`               | [toGlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/LanczosResample#toGlShaderProgram(android.content.Context,boolean))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Returns a[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)that applies the effect.                                                                                                         |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.media3.common.Effect](https://developer.android.com/reference/kotlin/androidx/media3/common/Effect) |-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | [getDurationAfterEffectApplied](https://developer.android.com/reference/kotlin/androidx/media3/common/Effect#getDurationAfterEffectApplied(long))`(durationUs: `[Long](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`. | |

## Public functions

### isNoOp

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

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

```
java-static fun scaleToFit(width: @IntRange(from = 1) Int, height: @IntRange(from = 1) Int): LanczosResample!
```

Creates an instance.  

|                                                                                         Parameters                                                                                         |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
| `width: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)  | The width inside which the output contents will fit.  |
| `height: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The height inside which the output contents will fit. |

### scaleToFitWithFlexibleOrientation

```
java-static fun scaleToFitWithFlexibleOrientation(
    firstDimension: @IntRange(from = 1) Int,
    secondDimension: @IntRange(from = 1) Int
): LanczosResample!
```

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[Size](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Size)passed in to[configure](https://developer.android.com/reference/kotlin/androidx/media3/effect/LanczosResample.LanczosResampleScaledFunctionProvider#configure(androidx.media3.common.util.Size)).  

|                                                                                             Parameters                                                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| `firstDimension: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)  | The first dimension of the output contents.  |
| `secondDimension: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The second dimension of the output contents. |

### toGlShaderProgram

```
fun toGlShaderProgram(context: Context!, useHdr: Boolean): GlShaderProgram!
```

Returns a[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)that applies the effect.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | A[Context](https://developer.android.com/reference/android/content/Context.html).                                                               |
| `useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [androidx.media3.common.VideoFrameProcessingException](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException) | If an error occurs while creating the[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram). |