# SizeLimitedBitmapLoader

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

*** ** * ** ***

<br />

```
@UnstableApi
class SizeLimitedBitmapLoader : BitmapLoader
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/media3/common/util/BitmapLoader` that limits the size of bitmaps loaded by `https://developer.android.com/reference/kotlin/androidx/media3/session/SizeLimitedBitmapLoader#decodeBitmap(byte[])` or `https://developer.android.com/reference/kotlin/androidx/media3/session/SizeLimitedBitmapLoader#loadBitmap(android.net.Uri)` request. Bitmaps with width or height larger than maxBitmapSize will be scaled down so that the larger dimension will be equal or less than maxBitmapSize.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/SizeLimitedBitmapLoader#SizeLimitedBitmapLoader(androidx.media3.common.util.BitmapLoader,int,boolean)( bitmapLoader: https://developer.android.com/reference/kotlin/androidx/media3/common/util/BitmapLoader!, maxBitmapSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, makeShared: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Creates an instance that size limits the bitmap loaded by the `https://developer.android.com/reference/kotlin/androidx/media3/common/util/BitmapLoader`. |

| ### Public functions |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/android/graphics/Bitmap.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/SizeLimitedBitmapLoader#decodeBitmap(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Decodes an image from compressed binary data. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/android/graphics/Bitmap.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/SizeLimitedBitmapLoader#loadBitmap(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html!)` Loads an image from `uri`. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/android/graphics/Bitmap.html!>?` | `https://developer.android.com/reference/kotlin/androidx/media3/session/SizeLimitedBitmapLoader#loadBitmapFromMetadata(androidx.media3.common.MediaMetadata)(metadata: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata!)` Loads an image from `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/session/SizeLimitedBitmapLoader#supportsMimeType(java.lang.String)(mimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns whether the given `mimeType` is supported. |

## Public constructors

### SizeLimitedBitmapLoader

```
SizeLimitedBitmapLoader(
    bitmapLoader: BitmapLoader!,
    maxBitmapSize: Int,
    makeShared: Boolean
)
```

Creates an instance that size limits the bitmap loaded by the `https://developer.android.com/reference/kotlin/androidx/media3/common/util/BitmapLoader`.

| Parameters |
|---|---|
| `bitmapLoader: https://developer.android.com/reference/kotlin/androidx/media3/common/util/BitmapLoader!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/util/BitmapLoader`. |
| `maxBitmapSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum size to limit the loaded `https://developer.android.com/reference/android/graphics/Bitmap.html` instances to. |
| `makeShared: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | 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. |

## Public functions

### decodeBitmap

```
fun decodeBitmap(data: ByteArray<Byte>!): ListenableFuture<Bitmap!>!
```

Decodes an image from compressed binary data.

### loadBitmap

```
fun loadBitmap(uri: Uri!): ListenableFuture<Bitmap!>!
```

Loads an image from `uri`.

### loadBitmapFromMetadata

```
fun loadBitmapFromMetadata(metadata: MediaMetadata!): ListenableFuture<Bitmap!>?
```

Loads an image from `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata`. Returns null if `metadata` doesn't contain bitmap information.

By default, the method will try to decode an image from `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata#artworkData()` if it is present. Otherwise, the method will try to load an image from `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata#artworkUri()` if it is present. The method will return null if neither `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata#artworkData()` nor `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata#artworkUri()` is present.

### supportsMimeType

```
fun supportsMimeType(mimeType: String!): Boolean
```

Returns whether the given `mimeType` is supported.