BitmapFactoryImageDecoder


@UnstableApi
class BitmapFactoryImageDecoder : SimpleDecoder, ImageDecoder


An image decoder that uses BitmapFactory to decode images.

Only supports decoding one input buffer into one output buffer (i.e. one Bitmap alongside one timestamp)).

Summary

Nested types

A functional interface for turning byte arrays into bitmaps.

A factory for BitmapFactoryImageDecoder instances.

Public functions

String!

Returns the name of the decoder.

Protected functions

DecoderInputBuffer!

Creates a new input buffer.

ImageOutputBuffer!

Creates a new output buffer.

ImageDecoderException!

Creates an exception to propagate for an unexpected decode error.

ImageDecoderException?
decode(
    inputBuffer: DecoderInputBuffer!,
    outputBuffer: ImageOutputBuffer!,
    reset: Boolean
)

Decodes the inputBuffer and stores any decoded output in outputBuffer.

Inherited functions

From androidx.media3.exoplayer.image.ImageDecoder
abstract ImageOutputBuffer?

Returns the next decoded Bitmap in an ImageOutputBuffer.

abstract Unit

Queues an DecoderInputBuffer to the decoder.

From androidx.media3.decoder.SimpleDecoder
I?

Dequeues the next input buffer to be filled and queued to the decoder.

O?

Dequeues the next output buffer from the decoder.

Unit

Flushes the decoder.

Boolean

Returns whether a sample time is greater or equal to the output start time, if set.

Unit
queueInputBuffer(inputBuffer: I!)

Queues an input buffer to the decoder.

Unit

Releases the decoder.

Unit
@CallSuper
releaseOutputBuffer(outputBuffer: O!)

Releases an output buffer back to the decoder.

Unit

Sets the initial size of each input buffer.

Unit
setOutputStartTimeUs(outputStartTimeUs: Long)

Sets the timestamp from which output buffers should be produced, in microseconds.

Public functions

getName

fun getName(): String!

Returns the name of the decoder.

Returns
String!

The name of the decoder.

Protected functions

createInputBuffer

protected fun createInputBuffer(): DecoderInputBuffer!

Creates a new input buffer.

createOutputBuffer

protected fun createOutputBuffer(): ImageOutputBuffer!

Creates a new output buffer.

createUnexpectedDecodeException

protected fun createUnexpectedDecodeException(error: Throwable!): ImageDecoderException!

Creates an exception to propagate for an unexpected decode error.

Parameters
error: Throwable!

The unexpected decode error.

Returns
ImageDecoderException!

The exception to propagate.

decode

protected fun decode(
    inputBuffer: DecoderInputBuffer!,
    outputBuffer: ImageOutputBuffer!,
    reset: Boolean
): ImageDecoderException?

Decodes the inputBuffer and stores any decoded output in outputBuffer.

Parameters
inputBuffer: DecoderInputBuffer!

The buffer to decode.

outputBuffer: ImageOutputBuffer!

The output buffer to store decoded data. The output buffer will not be made available to dequeue if its timeUs is not at least the output start time or when it's marked with shouldBeSkipped. The output buffer may not have been populated in these cases.

reset: Boolean

Whether the decoder must be reset before decoding.

Returns
ImageDecoderException?

A decoder exception if an error occurred, or null if decoding was successful.