# BitmapFactoryImageDecoder

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/image/BitmapFactoryImageDecoder.java+class:androidx.media3.exoplayer.image.BitmapFactoryImageDecoder)

*** ** * ** ***


```
@UnstableApi
public final class BitmapFactoryImageDecoder extends SimpleDecoder<DecoderInputBuffer, ImageOutputBuffer, ImageDecoderException> implements ImageDecoder
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.media3.decoder.SimpleDecoder](https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder)\<[DecoderInputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer), [ImageOutputBuffer](https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer), [ImageDecoderException](https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoderException)\> ||
|   | ↳ | [androidx.media3.exoplayer.image.BitmapFactoryImageDecoder](https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder) |

*** ** * ** ***

An image decoder that uses `https://developer.android.com/reference/android/graphics/BitmapFactory.html` to decode images.

Only supports decoding one input buffer into one output buffer (i.e. one `https://developer.android.com/reference/android/graphics/Bitmap.html` alongside one timestamp)).

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder.Factory implements https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoder.Factory` A factory for `https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder` instances. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#getName()()` Returns the name of the decoder. |

| ### Protected methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer` | `https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#createInputBuffer()()` Creates a new input buffer. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer` | `https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#createOutputBuffer()()` Creates a new output buffer. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoderException` | `https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#createUnexpectedDecodeException(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable.html error)` Creates an exception to propagate for an unexpected decode error. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoderException` | `https://developer.android.com/reference/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#decode(androidx.media3.decoder.DecoderInputBuffer,androidx.media3.exoplayer.image.ImageOutputBuffer,boolean)( https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer inputBuffer, https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer outputBuffer, boolean reset )` Decodes the `inputBuffer` and stores any decoded output in `outputBuffer`. |

### Inherited methods

From [androidx.media3.exoplayer.image.ImageDecoder](https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoder) `abstract @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer` `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoder#dequeueOutputBuffer()()`

Returns the next decoded `https://developer.android.com/reference/android/graphics/Bitmap.html` in an `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer`.
`abstract void` `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoder#queueInputBuffer(androidx.media3.decoder.DecoderInputBuffer)(https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer inputBuffer)`

Queues an `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer` to the decoder.
From [androidx.media3.decoder.SimpleDecoder](https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder) `final @https://developer.android.com/reference/androidx/annotation/Nullable I` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#dequeueInputBuffer()()`

Dequeues the next input buffer to be filled and queued to the decoder.
`final @https://developer.android.com/reference/androidx/annotation/Nullable O` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#dequeueOutputBuffer()()`

Dequeues the next output buffer from the decoder.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#flush()()`

Flushes the decoder.
`final boolean` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#isAtLeastOutputStartTimeUs(long)(long timeUs)`

Returns whether a sample time is greater or equal to the `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#setOutputStartTimeUs(long)`, if set.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#queueInputBuffer(I)(I inputBuffer)`

Queues an input buffer to the decoder.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#release()()`

Releases the decoder.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#releaseOutputBuffer(O)(O outputBuffer)`

Releases an output buffer back to the decoder.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#setCallback(androidx.media3.decoder.Decoder.Callback,java.util.concurrent.Executor)(https://developer.android.com/reference/androidx/media3/decoder/Decoder.Callback callback, https://developer.android.com/reference/java/util/concurrent/Executor.html executor)`

Sets the callback and executor.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#setInitialInputBufferSize(int)(int size)`

Sets the initial size of each input buffer.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#setOutputStartTimeUs(long)(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 |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | 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 |
|---|---|
| `https://developer.android.com/reference/java/lang/Throwable.html error` | The unexpected decode error. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/image/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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer inputBuffer` | The buffer to decode. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer outputBuffer` | The output buffer to store decoded data. The output buffer will not be made available to dequeue if its `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#timeUs()` is not `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder#isAtLeastOutputStartTimeUs(long)` or when it's marked with `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#shouldBeSkipped()`. The output buffer may not have been populated in these cases. |
| `boolean reset` | Whether the decoder must be reset before decoding. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoderException` | A decoder exception if an error occurred, or null if decoding was successful. |