Commit a21b2c85 by tofunmi Committed by Tofunmi Adigun-Hameed

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
(cherry picked from commit 7740ccc9382c55e246f5b7e5ea4e120d99b662bc)
parent 35a37b47
...@@ -115,17 +115,10 @@ public final class DefaultAssetLoaderFactory implements AssetLoader.Factory { ...@@ -115,17 +115,10 @@ public final class DefaultAssetLoaderFactory implements AssetLoader.Factory {
return false; return false;
} }
if (localConfiguration.mimeType != null) { if (localConfiguration.mimeType != null) {
ImmutableList<String> supportedMimeTypes = return MimeTypes.isImage(localConfiguration.mimeType);
ImmutableList.of(
MimeTypes.IMAGE_PNG,
MimeTypes.IMAGE_WEBP,
MimeTypes.IMAGE_JPEG,
MimeTypes.IMAGE_HEIC,
MimeTypes.IMAGE_HEIF);
return supportedMimeTypes.contains(localConfiguration.mimeType);
} }
ImmutableList<String> supportedImageTypes = 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()); String uriPath = checkNotNull(localConfiguration.uri.getPath());
int fileExtensionStart = uriPath.lastIndexOf("."); int fileExtensionStart = uriPath.lastIndexOf(".");
if (fileExtensionStart < 0) { if (fileExtensionStart < 0) {
......
...@@ -45,7 +45,13 @@ import com.google.common.util.concurrent.MoreExecutors; ...@@ -45,7 +45,13 @@ import com.google.common.util.concurrent.MoreExecutors;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; 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.
*/
public final class ImageAssetLoader implements AssetLoader { public final class ImageAssetLoader implements AssetLoader {
/** An {@link AssetLoader.Factory} for {@link ImageAssetLoader} instances. */ /** An {@link AssetLoader.Factory} for {@link ImageAssetLoader} instances. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment