BitmapOverlay


@UnstableApi
abstract class BitmapOverlay : TextureOverlay

Known direct subclasses
DrawableOverlay

Creates a TextureOverlay from Drawable.

TextOverlay

Creates a TextureOverlay from text.


Creates TextureOverlays from Bitmaps.

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

Summary

Public constructors

Public functions

java-static BitmapOverlay!

Creates a BitmapOverlay that shows the overlayBitmap in the same position and size throughout the whole video.

java-static BitmapOverlay!
createStaticBitmapOverlay(
    overlayBitmap: Bitmap!,
    overlaySettings: OverlaySettings!
)

Creates a BitmapOverlay that shows the overlayBitmap in the same throughout the whole video.

java-static BitmapOverlay!
createStaticBitmapOverlay(
    context: Context!,
    overlayBitmapUri: Uri!,
    overlaySettings: OverlaySettings!
)

Creates a BitmapOverlay that shows the input at overlayBitmapUri with the same OverlaySettings throughout the whole video.

abstract Bitmap!
getBitmap(presentationTimeUs: Long)

Returns the overlay bitmap displayed at the specified timestamp.

Int
getTextureId(presentationTimeUs: Long)

Returns the overlay texture identifier displayed at the specified timestamp.

Size!
getTextureSize(presentationTimeUs: Long)

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

FloatArray<Float>!
getVertexTransformation(presentationTimeUs: Long)

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

Unit

Releases all resources.

Inherited functions

From androidx.media3.effect.TextureOverlay
Unit
configure(videoSize: Size!)

Set up resources for the overlay given the input video’s dimensions.

OverlaySettings!
getOverlaySettings(presentationTimeUs: Long)

Returns the OverlaySettings controlling how the overlay is displayed at the specified timestamp.

Public constructors

BitmapOverlay

BitmapOverlay()

Public functions

createStaticBitmapOverlay

java-static fun createStaticBitmapOverlay(overlayBitmap: Bitmap!): BitmapOverlay!

Creates a BitmapOverlay that shows the overlayBitmap in the same position and size throughout the whole video.

Parameters
overlayBitmap: Bitmap!

The bitmap to overlay on the video.

createStaticBitmapOverlay

java-static fun createStaticBitmapOverlay(
    overlayBitmap: Bitmap!,
    overlaySettings: OverlaySettings!
): BitmapOverlay!

Creates a BitmapOverlay that shows the overlayBitmap in the same throughout the whole video.

Parameters
overlayBitmap: Bitmap!

The bitmap to overlay on the video.

overlaySettings: OverlaySettings!

The OverlaySettings configuring how the overlay is displayed on the frames.

createStaticBitmapOverlay

java-static fun createStaticBitmapOverlay(
    context: Context!,
    overlayBitmapUri: Uri!,
    overlaySettings: OverlaySettings!
): BitmapOverlay!

Creates a BitmapOverlay that shows the input at overlayBitmapUri with the same OverlaySettings throughout the whole video.

Parameters
context: Context!

The Context.

overlayBitmapUri: Uri!

The Uri pointing to the resource to be converted into a bitmap.

overlaySettings: OverlaySettings!

The OverlaySettings configuring how the overlay is displayed on the frames.

getBitmap

abstract fun getBitmap(presentationTimeUs: Long): Bitmap!

Returns the overlay bitmap displayed at the specified timestamp.

Parameters
presentationTimeUs: Long

The presentation timestamp of the current frame, in microseconds.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while processing or drawing the frame.

getTextureId

fun getTextureId(presentationTimeUs: Long): Int

Returns the overlay texture identifier displayed at the specified timestamp.

Parameters
presentationTimeUs: Long

The presentation timestamp of the current frame, in microseconds.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while processing or drawing the frame.

getTextureSize

fun getTextureSize(presentationTimeUs: Long): Size!

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
presentationTimeUs: Long

The presentation timestamp of the current frame, in microseconds.

getVertexTransformation

fun getVertexTransformation(presentationTimeUs: Long): FloatArray<Float>!

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

Applied before overlay settings.

Parameters
presentationTimeUs: Long

The presentation timestamp of the current frame, in microseconds.

release

fun release(): Unit

Releases all resources.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while releasing resources.