BitmapFactoryImageDecoder


@UnstableApi
public final class BitmapFactoryImageDecoder extends SimpleDecoder implements 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 methods

String

Returns the name of the decoder.

Protected methods

DecoderInputBuffer

Creates a new input buffer.

ImageOutputBuffer

Creates a new output buffer.

ImageDecoderException

Creates an exception to propagate for an unexpected decode error.

@Nullable ImageDecoderException
decode(
    DecoderInputBuffer inputBuffer,
    ImageOutputBuffer outputBuffer,
    boolean reset
)

Decodes the inputBuffer and stores any decoded output in outputBuffer.

Inherited methods

From androidx.media3.exoplayer.image.ImageDecoder
abstract @Nullable ImageOutputBuffer

Returns the next decoded Bitmap in an ImageOutputBuffer.

abstract void

Queues an DecoderInputBuffer to the decoder.

From androidx.media3.decoder.SimpleDecoder
final @Nullable I

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

final @Nullable O

Dequeues the next output buffer from the decoder.

final void

Flushes the decoder.

final boolean

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

final void
queueInputBuffer(I inputBuffer)

Queues an input buffer to the decoder.

void

Releases the decoder.

void

Releases an output buffer back to the decoder.

final void

Sets the initial size of each input buffer.

final void
setOutputStartTimeUs(long outputStartTimeUs)

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

Public methods

getName

public String getName()

Returns the name of the decoder.

Returns
String

The name of the decoder.

Protected methods

createInputBuffer

protected DecoderInputBuffer createInputBuffer()

Creates a new input buffer.

createOutputBuffer

protected ImageOutputBuffer createOutputBuffer()

Creates a new output buffer.

createUnexpectedDecodeException

protected ImageDecoderException createUnexpectedDecodeException(Throwable error)

Creates an exception to propagate for an unexpected decode error.

Parameters
Throwable error

The unexpected decode error.

Returns
ImageDecoderException

The exception to propagate.

decode

protected @Nullable ImageDecoderException decode(
    DecoderInputBuffer inputBuffer,
    ImageOutputBuffer outputBuffer,
    boolean reset
)

Decodes the inputBuffer and stores any decoded output in outputBuffer.

Parameters
DecoderInputBuffer inputBuffer

The buffer to decode.

ImageOutputBuffer outputBuffer

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.

boolean reset

Whether the decoder must be reset before decoding.

Returns
@Nullable ImageDecoderException

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