From bc22b02612260ead6991558690286b25d698cfa3 Mon Sep 17 00:00:00 2001 From: judds Date: Wed, 18 Apr 2018 15:56:08 -0700 Subject: [PATCH] Automated g4 rollback of changelist 192690571. *** Reason for rollback *** b/78110139 *** Original change description *** Use ExifInterface to parse orientation data on OMR1+ in Glide. *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=193431565 --- .../main/java/com/bumptech/glide/Glide.java | 9 ---- .../ExifInterfaceImageHeaderParser.java | 47 ------------------- 2 files changed, 56 deletions(-) delete mode 100644 library/src/main/java/com/bumptech/glide/load/resource/bitmap/ExifInterfaceImageHeaderParser.java diff --git a/library/src/main/java/com/bumptech/glide/Glide.java b/library/src/main/java/com/bumptech/glide/Glide.java index f200fa96c..ea9fcea8f 100644 --- a/library/src/main/java/com/bumptech/glide/Glide.java +++ b/library/src/main/java/com/bumptech/glide/Glide.java @@ -11,7 +11,6 @@ import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.ParcelFileDescriptor; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -55,7 +54,6 @@ import com.bumptech.glide.load.resource.bitmap.BitmapEncoder; import com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder; import com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser; import com.bumptech.glide.load.resource.bitmap.Downsampler; -import com.bumptech.glide.load.resource.bitmap.ExifInterfaceImageHeaderParser; import com.bumptech.glide.load.resource.bitmap.ResourceBitmapDecoder; import com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder; import com.bumptech.glide.load.resource.bitmap.UnitBitmapDecoder; @@ -333,13 +331,6 @@ public class Glide implements ComponentCallbacks2 { final Resources resources = context.getResources(); registry = new Registry(); - // Right now we're only using this parser for HEIF images, which are only supported on OMR1+. - // If we need this for other file types, we should consider removing this restriction. - // Note that order here matters. We want to check the ExifInterface parser first for orientation - // and then fall back to DefaultImageHeaderParser for other fields. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { - registry.register(new ExifInterfaceImageHeaderParser()); - } registry.register(new DefaultImageHeaderParser()); Downsampler downsampler = new Downsampler(registry.getImageHeaderParsers(), diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/ExifInterfaceImageHeaderParser.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/ExifInterfaceImageHeaderParser.java deleted file mode 100644 index cffaf2bd4..000000000 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/ExifInterfaceImageHeaderParser.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.bumptech.glide.load.resource.bitmap; - -import android.media.ExifInterface; -import android.support.annotation.NonNull; -import com.bumptech.glide.load.ImageHeaderParser; -import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool; -import com.bumptech.glide.util.ByteBufferUtil; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; - -/** - * Uses {@link ExifInterface} to parse orientation data. - * - *

ExifInterface supports the HEIF format on OMR1+. Glide's {@link DefaultImageHeaderParser} - * doesn't currently support HEIF. In the future we should reconcile these two classes, but for - * now this is a simple way to ensure that HEIF files are oriented correctly on platforms where - * they're supported. - */ -public final class ExifInterfaceImageHeaderParser implements ImageHeaderParser { - - @NonNull - @Override - public ImageType getType(@NonNull InputStream is) throws IOException { - return ImageType.UNKNOWN; - } - - @NonNull - @Override - public ImageType getType(@NonNull ByteBuffer byteBuffer) throws IOException { - return ImageType.UNKNOWN; - } - - @Override - public int getOrientation(@NonNull InputStream is, @NonNull ArrayPool byteArrayPool) - throws IOException { - ExifInterface exifInterface = new ExifInterface(is); - return exifInterface.getAttributeInt( - ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); - } - - @Override - public int getOrientation(@NonNull ByteBuffer byteBuffer, @NonNull ArrayPool byteArrayPool) - throws IOException { - return getOrientation(ByteBufferUtil.toStream(byteBuffer), byteArrayPool); - } -} -- GitLab