Skip to content

Commit bfae3d8

Browse files
committed
Address comments for PR #5475
1 parent 484366a commit bfae3d8

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

library/src/main/java/com/bumptech/glide/load/ImageHeaderParserUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private static int getOrientationInternal(
239239
* Returns the result from the first of {@code parsers} that returns true when MPF is detected, if
240240
* any..
241241
*
242-
* <p>If {@code buffer} is null, the parers list is empty, or none of the parsers returns a valid
242+
* <p>If {@code buffer} is null, the parsers list is empty, or none of the parsers returns a valid
243243
* value, false is returned.
244244
*/
245245
public static boolean hasJpegMpf(

library/src/main/java/com/bumptech/glide/load/resource/bitmap/DefaultImageHeaderParser.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,22 +354,33 @@ private int moveToExifSegmentAndGetLength(Reader reader) throws IOException {
354354
return moveToSegmentAndGetLength(reader, EXIF_SEGMENT_TYPE);
355355
}
356356

357-
private boolean hasJpegMpfPreamble(Reader reader, byte[] tempArray, int mpfSegmentLength)
357+
/**
358+
* Returns whether the reader, set at the beginning of the APP2 segment past the length bytes,
359+
* contains multi-picture format (MPF) data.
360+
*
361+
* @param reader must be set at the start of an APP2 segment, past the APP2 label and length
362+
* bytes.
363+
* @param tempArray for storing temporary array. Must be at least the size of
364+
* {@code app2SegmentLength}.
365+
* @param app2SegmentLength the length of the APP2 segment.
366+
* @throws IOException if an EOF is reached before anything was read.
367+
*/
368+
private boolean hasJpegMpfPreamble(Reader reader, byte[] tempArray, int app2SegmentLength)
358369
throws IOException {
359-
int read = reader.read(tempArray, mpfSegmentLength);
360-
if (read != mpfSegmentLength) {
370+
int read = reader.read(tempArray, app2SegmentLength);
371+
if (read != app2SegmentLength) {
361372
if (Log.isLoggable(TAG, Log.DEBUG)) {
362373
Log.d(
363374
TAG,
364-
"Unable to read MPF segment data"
375+
"Unable to read APP2 segment data"
365376
+ ", length: "
366-
+ mpfSegmentLength
377+
+ app2SegmentLength
367378
+ ", actually read: "
368379
+ read);
369380
}
370381
return false;
371382
}
372-
return hasMatchingBytes(tempArray, mpfSegmentLength, JPEG_MPF_SEGMENT_PREAMBLE_BYTES);
383+
return hasMatchingBytes(tempArray, app2SegmentLength, JPEG_MPF_SEGMENT_PREAMBLE_BYTES);
373384
}
374385

375386
private int moveToApp2SegmentAndGetLength(Reader reader) throws IOException {

library/src/main/java/com/bumptech/glide/load/resource/bitmap/ImageReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public int getImageOrientation() throws IOException {
145145
public boolean hasJpegMpf() throws IOException {
146146
InputStream is = null;
147147
try {
148-
is = new RecyclableBufferedInputStream(new FileInputStream(file), byteArrayPool);
148+
is = new FileInputStream(file);
149149
return ImageHeaderParserUtils.hasJpegMpf(parsers, is, byteArrayPool);
150150
} finally {
151151
if (is != null) {

0 commit comments

Comments
 (0)