# BitmapLoader

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

*** ** * ** ***

<br />

```
@UnstableApi
public interface BitmapLoader
```

<br />

Known direct subclasses [BitmapLoader](https://developer.android.com/reference/androidx/media3/session/BitmapLoader), [CacheBitmapLoader](https://developer.android.com/reference/androidx/media3/session/CacheBitmapLoader), [DataSourceBitmapLoader](https://developer.android.com/reference/androidx/media3/datasource/DataSourceBitmapLoader), [SimpleBitmapLoader](https://developer.android.com/reference/androidx/media3/session/SimpleBitmapLoader), [SizeLimitedBitmapLoader](https://developer.android.com/reference/androidx/media3/session/SizeLimitedBitmapLoader)

|---|---|
| `https://developer.android.com/reference/androidx/media3/session/BitmapLoader` | **This interface is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/util/BitmapLoader` instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/session/CacheBitmapLoader` | A `https://developer.android.com/reference/androidx/media3/common/util/BitmapLoader` that caches the result of the last `https://developer.android.com/reference/androidx/media3/session/CacheBitmapLoader#decodeBitmap(byte[])`, `https://developer.android.com/reference/androidx/media3/session/CacheBitmapLoader#loadBitmap(android.net.Uri)` or `https://developer.android.com/reference/androidx/media3/session/CacheBitmapLoader#loadBitmapFromMetadata(androidx.media3.common.MediaMetadata)` request. |
| `https://developer.android.com/reference/androidx/media3/datasource/DataSourceBitmapLoader` | A `https://developer.android.com/reference/androidx/media3/common/util/BitmapLoader` implementation that uses a `https://developer.android.com/reference/androidx/media3/datasource/DataSource` to support fetching images from URIs and `https://developer.android.com/reference/android/graphics/BitmapFactory.html` to load them into `https://developer.android.com/reference/android/graphics/Bitmap.html`. |
| `https://developer.android.com/reference/androidx/media3/session/SimpleBitmapLoader` | **This class is deprecated.** Use `https://developer.android.com/reference/androidx/media3/datasource/DataSourceBitmapLoader` instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/session/SizeLimitedBitmapLoader` | A `https://developer.android.com/reference/androidx/media3/common/util/BitmapLoader` that limits the size of bitmaps loaded by `https://developer.android.com/reference/androidx/media3/session/SizeLimitedBitmapLoader#decodeBitmap(byte[])` or `https://developer.android.com/reference/androidx/media3/session/SizeLimitedBitmapLoader#loadBitmap(android.net.Uri)` request. |

*** ** * ** ***

Loads images.

## Summary

| ### Public methods |
|---|---|
| `abstract 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/androidx/media3/common/util/BitmapLoader#decodeBitmap(byte[])(byte[] data)` Decodes an image from compressed binary data. |
| `abstract 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/androidx/media3/common/util/BitmapLoader#loadBitmap(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html uri)` Loads an image from `uri`. |
| `default @https://developer.android.com/reference/androidx/annotation/Nullable 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/androidx/media3/common/util/BitmapLoader#loadBitmapFromMetadata(androidx.media3.common.MediaMetadata)(https://developer.android.com/reference/androidx/media3/common/MediaMetadata metadata)` Loads an image from `https://developer.android.com/reference/androidx/media3/common/MediaMetadata`. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/common/util/BitmapLoader#supportsMimeType(java.lang.String)(https://developer.android.com/reference/java/lang/String.html mimeType)` Returns whether the given `mimeType` is supported. |

## Public methods

### decodeBitmap

```
abstract ListenableFuture<Bitmap> decodeBitmap(byte[] data)
```

Decodes an image from compressed binary data.

### loadBitmap

```
abstract ListenableFuture<Bitmap> loadBitmap(Uri uri)
```

Loads an image from `uri`.

### loadBitmapFromMetadata

```
default @Nullable ListenableFuture<Bitmap> loadBitmapFromMetadata(MediaMetadata metadata)
```

Loads an image from `https://developer.android.com/reference/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/androidx/media3/common/MediaMetadata#artworkData()` if it is present. Otherwise, the method will try to load an image from `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#artworkUri()` if it is present. The method will return null if neither `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#artworkData()` nor `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#artworkUri()` is present.

### supportsMimeType

```
abstract boolean supportsMimeType(String mimeType)
```

Returns whether the given `mimeType` is supported.