# 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
class BitmapFactoryImageDecoder : SimpleDecoder<DecoderInputBuffer!, ImageOutputBuffer!, ImageDecoderException!>, ImageDecoder
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.media3.decoder.SimpleDecoder](https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder)\<[DecoderInputBuffer](https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer)!, [ImageOutputBuffer](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageOutputBuffer)!, [ImageDecoderException](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageDecoderException)!\> ||
|   | ↳ | [androidx.media3.exoplayer.image.BitmapFactoryImageDecoder](https://developer.android.com/reference/kotlin/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 |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder.Factory : https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageDecoder.Factory` A factory for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder` instances. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#getName()()` Returns the name of the decoder. |

| ### Protected functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#createInputBuffer()()` Creates a new input buffer. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageOutputBuffer!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#createOutputBuffer()()` Creates a new output buffer. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageDecoderException!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#createUnexpectedDecodeException(java.lang.Throwable)(error: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` Creates an exception to propagate for an unexpected decode error. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageDecoderException?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/BitmapFactoryImageDecoder#decode(androidx.media3.decoder.DecoderInputBuffer,androidx.media3.exoplayer.image.ImageOutputBuffer,boolean)( inputBuffer: https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer!, outputBuffer: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageOutputBuffer!, reset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Decodes the `inputBuffer` and stores any decoded output in `outputBuffer`. |

### Inherited functions

From [androidx.media3.exoplayer.image.ImageDecoder](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageDecoder) `abstract https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageOutputBuffer?` `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/exoplayer/image/ImageOutputBuffer`.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/image/ImageDecoder#queueInputBuffer(androidx.media3.decoder.DecoderInputBuffer)(inputBuffer: https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer!)`

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

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

Dequeues the next output buffer from the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#flush()()`

Flushes the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#isAtLeastOutputStartTimeUs(long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Returns whether a sample time is greater or equal to the `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setOutputStartTimeUs(long)`, if set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#queueInputBuffer(I)(inputBuffer: I!)`

Queues an input buffer to the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#release()()`

Releases the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#releaseOutputBuffer(O)(outputBuffer: O!)`

Releases an output buffer back to the decoder.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setCallback(androidx.media3.decoder.Decoder.Callback,java.util.concurrent.Executor)(callback: https://developer.android.com/reference/kotlin/androidx/media3/decoder/Decoder.Callback!, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html!)`

Sets the callback and executor.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setInitialInputBufferSize(int)(size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the initial size of each input buffer.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/SimpleDecoder#setOutputStartTimeUs(long)(outputStartTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | 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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | The unexpected decode error. |

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

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