@ VisibleForTesting @ Nullable static CloseableReference < Bitmap > convertToBitmapReferenceAndClose ( final @ Nullable CloseableReference < CloseableImage > closeableImage ) { try { if ( CloseableReference . isValid ( closeableImage ) && closeableImage . get ( ) instanceof CloseableStaticBitmap ) { CloseableStaticBitmap closeableStaticBitmap = ( CloseableStaticBitmap ) closeableImage . get ( ) ; if ( closeableStaticBitmap != null ) { // We return a clone of the underlying bitmap reference that has to be manually closed // and then close the passed CloseableStaticBitmap in order to preserve correct // cache size calculations. return closeableStaticBitmap . cloneUnderlyingBitmapReference ( ) ; } } // Not a bitmap reference, so we return null return null ; } finally { CloseableReference . closeSafely ( closeableImage ) ; } }
Converts the given image reference to a bitmap reference and closes the original image reference .