# BitmapOverlay

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

*** ** * ** ***


```
@UnstableApi
public abstract class BitmapOverlay extends TextureOverlay
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.media3.effect.TextureOverlay](https://developer.android.com/reference/androidx/media3/effect/TextureOverlay) ||
|   | ↳ | [androidx.media3.effect.BitmapOverlay](https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay) |

Known direct subclasses [CanvasOverlay](https://developer.android.com/reference/androidx/media3/effect/CanvasOverlay), [DrawableOverlay](https://developer.android.com/reference/androidx/media3/effect/DrawableOverlay), [TextOverlay](https://developer.android.com/reference/androidx/media3/effect/TextOverlay)

|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/CanvasOverlay` | A `https://developer.android.com/reference/androidx/media3/effect/TextOverlay` that is backed by a `https://developer.android.com/reference/android/graphics/Canvas.html`. |
| `https://developer.android.com/reference/androidx/media3/effect/DrawableOverlay` | Creates a `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay` from `https://developer.android.com/reference/android/graphics/drawable/Drawable.html`. |
| `https://developer.android.com/reference/androidx/media3/effect/TextOverlay` | Creates a `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay` from text. |

Known indirect subclasses [LottieOverlay](https://developer.android.com/reference/androidx/media3/effect/lottie/LottieOverlay)

|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/lottie/LottieOverlay` | A `https://developer.android.com/reference/androidx/media3/effect/CanvasOverlay` that renders a Lottie animation. |

*** ** * ** ***

Creates `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay`s from `https://developer.android.com/reference/android/graphics/Bitmap.html`s.

Useful for overlaying images and animated images (e.g. GIFs).

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#BitmapOverlay()()` |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#createStaticBitmapOverlay(android.graphics.Bitmap)(https://developer.android.com/reference/android/graphics/Bitmap.html overlayBitmap)` Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the `overlayBitmap` in the same position and size throughout the whole video. |
| `static https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#createStaticBitmapOverlay(android.graphics.Bitmap,androidx.media3.effect.StaticOverlaySettings)( https://developer.android.com/reference/android/graphics/Bitmap.html overlayBitmap, https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings )` Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the `overlayBitmap` in the same `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` throughout the whole video. |
| `static https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#createStaticBitmapOverlay(android.content.Context,android.net.Uri,androidx.media3.effect.StaticOverlaySettings)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/net/Uri.html overlayBitmapUri, https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings )` Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the input at `overlayBitmapUri` with the same `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` throughout the whole video. |
| `abstract https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#getBitmap(long)(long presentationTimeUs)` Returns the overlay bitmap displayed at the specified timestamp. |
| `int` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#getTextureId(long)(long presentationTimeUs)` Returns the overlay texture identifier displayed at the specified timestamp. |
| `https://developer.android.com/reference/androidx/media3/common/util/Size` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#getTextureSize(long)(long presentationTimeUs)` Returns the pixel width and height of the overlay texture displayed at the specified timestamp. |
| `float[]` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#getVertexTransformation(long)(long presentationTimeUs)` Returns a 4x4 OpenGL matrix, controlling how the vertices of the overlay are displayed at the specified timestamp. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#release()()` Releases all resources. |

| ### Inherited methods |
|---|
| From [androidx.media3.effect.TextureOverlay](https://developer.android.com/reference/androidx/media3/effect/TextureOverlay) |---|---| | `void` | `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay#configure(androidx.media3.common.util.Size)(https://developer.android.com/reference/androidx/media3/common/util/Size videoSize)` Set up resources for the overlay given the input video's dimensions. | | `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` | `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay#getOverlaySettings(long)(long presentationTimeUs)` Returns the `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` controlling how the overlay is displayed at the specified timestamp. | |

## Public constructors

### BitmapOverlay

```
public BitmapOverlay()
```

## Public methods

### createStaticBitmapOverlay

```
public static BitmapOverlay createStaticBitmapOverlay(Bitmap overlayBitmap)
```

Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the `overlayBitmap` in the same position and size throughout the whole video.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html overlayBitmap` | The bitmap to overlay on the video. |

### createStaticBitmapOverlay

```
public static BitmapOverlay createStaticBitmapOverlay(
    Bitmap overlayBitmap,
    StaticOverlaySettings overlaySettings
)
```

Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the `overlayBitmap` in the same `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` throughout the whole video.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html overlayBitmap` | The bitmap to overlay on the video. |
| `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings` | The `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` configuring how the overlay is displayed on the frames. |

### createStaticBitmapOverlay

```
public static BitmapOverlay createStaticBitmapOverlay(
    Context context,
    Uri overlayBitmapUri,
    StaticOverlaySettings overlaySettings
)
```

Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the input at `overlayBitmapUri` with the same `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` throughout the whole video.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `https://developer.android.com/reference/android/net/Uri.html overlayBitmapUri` | The `https://developer.android.com/reference/android/net/Uri.html` pointing to the resource to be converted into a bitmap. |
| `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings` | The `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` configuring how the overlay is displayed on the frames. |

### getBitmap

```
public abstract Bitmap getBitmap(long presentationTimeUs)
```

Returns the overlay bitmap displayed at the specified timestamp.

| Parameters |
|---|---|
| `long presentationTimeUs` | The presentation timestamp of the current frame, in microseconds. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while processing or drawing the frame. |

### getTextureId

```
public int getTextureId(long presentationTimeUs)
```

Returns the overlay texture identifier displayed at the specified timestamp.

| Parameters |
|---|---|
| `long presentationTimeUs` | The presentation timestamp of the current frame, in microseconds. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while processing or drawing the frame. |

### getTextureSize

```
public Size getTextureSize(long presentationTimeUs)
```

Returns the pixel width and height of the overlay texture displayed at the specified timestamp.

This method must be called after #getTextureId(long).

Gets the width and height of the cached bitmap.

| Parameters |
|---|---|
| `long presentationTimeUs` | The presentation timestamp of the current frame, in microseconds. |

### getVertexTransformation

```
public float[] getVertexTransformation(long presentationTimeUs)
```

Returns a 4x4 OpenGL matrix, controlling how the vertices of the overlay are displayed at the specified timestamp.

Applied before #getOverlaySettings overlay settings.

Flips the overlay vertically to convert between Android and OpenGL texture coordinate systems.

### release

```
public void release()
```

Releases all resources.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while releasing resources. |