diff --git a/library/src/main/java/com/bumptech/glide/load/ImageHeaderParserUtils.java b/library/src/main/java/com/bumptech/glide/load/ImageHeaderParserUtils.java index 2e73dfa1c5..d1d821efcb 100644 --- a/library/src/main/java/com/bumptech/glide/load/ImageHeaderParserUtils.java +++ b/library/src/main/java/com/bumptech/glide/load/ImageHeaderParserUtils.java @@ -239,7 +239,7 @@ private static int getOrientationInternal( * Returns the result from the first of {@code parsers} that returns true when MPF is detected, if * any.. * - *
If {@code buffer} is null, the parers list is empty, or none of the parsers returns a valid + *
If {@code buffer} is null, the parsers list is empty, or none of the parsers returns a valid * value, false is returned. */ public static boolean hasJpegMpf( diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java index 87b36fa0db..523cc7520c 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java @@ -354,22 +354,33 @@ private int moveToExifSegmentAndGetLength(Reader reader) throws IOException { return moveToSegmentAndGetLength(reader, EXIF_SEGMENT_TYPE); } - private boolean hasJpegMpfPreamble(Reader reader, byte[] tempArray, int mpfSegmentLength) + /** + * Returns whether the reader, set at the beginning of the APP2 segment past the length bytes, + * contains multi-picture format (MPF) data. + * + * @param reader must be set at the start of an APP2 segment, past the APP2 label and length + * bytes. + * @param tempArray for storing temporary array. Must be at least the size of + * {@code app2SegmentLength}. + * @param app2SegmentLength the length of the APP2 segment. + * @throws IOException if an EOF is reached before anything was read. + */ + private boolean hasJpegMpfPreamble(Reader reader, byte[] tempArray, int app2SegmentLength) throws IOException { - int read = reader.read(tempArray, mpfSegmentLength); - if (read != mpfSegmentLength) { + int read = reader.read(tempArray, app2SegmentLength); + if (read != app2SegmentLength) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d( TAG, - "Unable to read MPF segment data" + "Unable to read APP2 segment data" + ", length: " - + mpfSegmentLength + + app2SegmentLength + ", actually read: " + read); } return false; } - return hasMatchingBytes(tempArray, mpfSegmentLength, JPEG_MPF_SEGMENT_PREAMBLE_BYTES); + return hasMatchingBytes(tempArray, app2SegmentLength, JPEG_MPF_SEGMENT_PREAMBLE_BYTES); } private int moveToApp2SegmentAndGetLength(Reader reader) throws IOException { diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/ImageReader.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/ImageReader.java index 8ecc3dd852..835652fe03 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/ImageReader.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/ImageReader.java @@ -145,7 +145,7 @@ public int getImageOrientation() throws IOException { public boolean hasJpegMpf() throws IOException { InputStream is = null; try { - is = new RecyclableBufferedInputStream(new FileInputStream(file), byteArrayPool); + is = new FileInputStream(file); return ImageHeaderParserUtils.hasJpegMpf(parsers, is, byteArrayPool); } finally { if (is != null) {