Skip to content

Commit

Permalink
Avoid using hardware Bitmaps if we're unable to determine the source …
Browse files Browse the repository at this point in the history
…dimensions

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169726622
  • Loading branch information
sjudd committed Sep 26, 2017
1 parent 7457b9d commit f9757a5
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ private Bitmap decodeFromWrappedStreams(InputStream is,
int sourceHeight = sourceDimensions[1];
String sourceMimeType = options.outMimeType;

// If we failed to obtain the image dimensions, we may end up with an incorrectly sized Bitmap,
// so we want to use a mutable Bitmap type. One way this can happen is if the image header is so
// large (10mb+) that our attempt to use inJustDecodeBounds fails and we're forced to decode the
// full size image.
if (sourceWidth == -1 || sourceHeight == -1) {
isHardwareConfigAllowed = false;
}

int orientation = ImageHeaderParserUtils.getOrientation(parsers, is, byteArrayPool);
int degreesToRotate = TransformationUtils.getExifOrientationDegrees(orientation);
boolean isExifOrientationRequired = TransformationUtils.isExifOrientationRequired(orientation);
Expand Down

0 comments on commit f9757a5

Please sign in to comment.