# DataSourceBitmapLoader.Builder

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

*** ** * ** ***


```
class DataSourceBitmapLoader.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder#Builder(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html!)` Creates a builder. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder#build()()` Builds a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder#setBitmapFactoryOptions(android.graphics.BitmapFactory.Options)(options: https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html?)` Sets the `https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html` to be used for decoding bitmaps. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder#setDataSourceFactory(androidx.media3.datasource.DataSource.Factory)(dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory!)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory` to be used to create `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` instances for loading bitmaps. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder#setExecutorService(com.google.common.util.concurrent.ListeningExecutorService)(listeningExecutorService: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html!)` Sets the `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html` to be used for loading bitmaps. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder#setMakeShared(boolean)(makeShared: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether the `https://developer.android.com/reference/android/graphics/Bitmap.html` should be converted to an immutable, sharable instance that is most efficient for repeated transfer over binder interfaces. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder#setMaximumOutputDimension(int)(maximumOutputDimension: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the maximum output dimension for decoded bitmaps. |

## Public constructors

### Builder

```
Builder(context: Context!)
```

Creates a builder.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html!` | The context. |

## Public functions

### build

```
fun build(): DataSourceBitmapLoader!
```

Builds a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader`.

### setBitmapFactoryOptions

```
@CanIgnoreReturnValue
fun setBitmapFactoryOptions(options: BitmapFactory.Options?): DataSourceBitmapLoader.Builder!
```

Sets the `https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html` to be used for decoding bitmaps.

| Parameters |
|---|---|
| `options: https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html?` | A `https://developer.android.com/reference/android/graphics/BitmapFactory.Options.html`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | This builder. |

### setDataSourceFactory

```
@CanIgnoreReturnValue
fun setDataSourceFactory(dataSourceFactory: DataSource.Factory!): DataSourceBitmapLoader.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory` to be used to create `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` instances for loading bitmaps.

If not set, a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DefaultDataSource.Factory` will be used.

| Parameters |
|---|---|
| `dataSourceFactory: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory!` | A `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource.Factory`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | This builder. |

### setExecutorService

```
@CanIgnoreReturnValue
fun setExecutorService(listeningExecutorService: ListeningExecutorService!): DataSourceBitmapLoader.Builder!
```

Sets the `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html` to be used for loading bitmaps.

If not set, `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader#DEFAULT_EXECUTOR_SERVICE()` will be used.

| Parameters |
|---|---|
| `listeningExecutorService: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html!` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListeningExecutorService.html`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | This builder. |

### setMakeShared

```
@CanIgnoreReturnValue
fun setMakeShared(makeShared: Boolean): DataSourceBitmapLoader.Builder!
```

Sets whether the `https://developer.android.com/reference/android/graphics/Bitmap.html` should be converted to an immutable, sharable instance that is most efficient for repeated transfer over binder interfaces.

| Parameters |
|---|---|
| `makeShared: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to make the `https://developer.android.com/reference/android/graphics/Bitmap.html` shared. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | This builder. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/BitmapUtil#makeShared(android.graphics.Bitmap)` |   |

### setMaximumOutputDimension

```
@CanIgnoreReturnValue
fun setMaximumOutputDimension(maximumOutputDimension: Int): DataSourceBitmapLoader.Builder!
```

Sets the maximum output dimension for decoded bitmaps.

The decoder downscales the image using power-of-2 `inSampleSize` (subsampling) until the larger dimension is less than or equal to the maximum output dimension.

Note: Because only power-of-2 scaling is supported during decoding, the returned bitmap can be significantly smaller than the requested maximum output dimension if the original size is just above the limit (e.g. decoding a 1080px image with a 900px limit results in a 540px image). If you need the bitmap to be scaled closer to the limit, you may need to post-process the decoded bitmap or wrap this loader in a custom loader that performs precise scaling.

| Parameters |
|---|---|
| `maximumOutputDimension: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum output dimension in pixels. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSourceBitmapLoader.Builder!` | This builder. |