/** * Parse the orientation from the image header. If it doesn't handle this image type (or this is * not an image) it will return a default value rather than throwing an exception. * * @return The exif orientation if present or -1 if the header couldn't be parsed or doesn't * contain an orientation */ private int getOrientation(Reader reader, ArrayPool byteArrayPool) throws IOException { final int magicNumber = reader.getUInt16(); if (!handles(magicNumber)) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Parser doesn't handle magic number: " + magicNumber); } return UNKNOWN_ORIENTATION; } else { int exifSegmentLength = moveToExifSegmentAndGetLength(reader); if (exifSegmentLength == -1) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Failed to parse exif segment length, or exif segment not found"); } return UNKNOWN_ORIENTATION; } byte[] exifData = byteArrayPool.get(exifSegmentLength, byte[].class); try { return parseExifSegment(reader, exifData, exifSegmentLength); } finally { byteArrayPool.put(exifData); } } }
int exifSegmentLength = moveToExifSegmentAndGetLength(reader); if (exifSegmentLength == -1) { if (Log.isLoggable(TAG, Log.DEBUG)) {