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:
parent
f4d1a6c453
commit
94d29f35fc
@ -117,17 +117,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) {
|
||||||
|
@ -46,7 +46,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.
|
||||||
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public final class ImageAssetLoader implements AssetLoader {
|
public final class ImageAssetLoader implements AssetLoader {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user