Image transcoding: Add support for bmp image format.

With this change we will now support loading bitmaps from all the formats documented [here](https://developer.android.com/guide/topics/media/media-formats#image-formats) except for gifs (because they are animated). Java doc is added to express this.

PiperOrigin-RevId: 535610152
This commit is contained in:
tofunmi 2023-05-26 14:16:28 +00:00 committed by Tofunmi Adigun-Hameed
parent f4d1a6c453
commit 94d29f35fc
2 changed files with 9 additions and 10 deletions

View File

@ -117,17 +117,10 @@ public final class DefaultAssetLoaderFactory implements AssetLoader.Factory {
return false;
}
if (localConfiguration.mimeType != null) {
ImmutableList<String> supportedMimeTypes =
ImmutableList.of(
MimeTypes.IMAGE_PNG,
MimeTypes.IMAGE_WEBP,
MimeTypes.IMAGE_JPEG,
MimeTypes.IMAGE_HEIC,
MimeTypes.IMAGE_HEIF);
return supportedMimeTypes.contains(localConfiguration.mimeType);
return MimeTypes.isImage(localConfiguration.mimeType);
}
ImmutableList<String> supportedImageTypes =
ImmutableList.of(".png", ".webp", ".jpg", ".jpeg", ".heic", ".heif");
ImmutableList.of(".png", ".webp", ".jpg", ".jpeg", ".heic", ".heif", ".bmp");
String uriPath = checkNotNull(localConfiguration.uri.getPath());
int fileExtensionStart = uriPath.lastIndexOf(".");
if (fileExtensionStart < 0) {

View File

@ -46,7 +46,13 @@ import com.google.common.util.concurrent.MoreExecutors;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
/** An {@link AssetLoader} implementation that loads images into {@link Bitmap} instances. */
/**
* An {@link AssetLoader} implementation that loads images into {@link Bitmap} instances.
*
* <p>Supports the image formats listed <a
* href="https://developer.android.com/guide/topics/media/media-formats#image-formats">here</a>
* except from GIFs, which could exhibit unexpected behavior.
*/
@UnstableApi
public final class ImageAssetLoader implements AssetLoader {