public synchronized Bitmap getBitmap ( BitmapFactory . Options options ) { Bitmap bitmap = null ; synchronized ( bitmapsBySize ) { final Iterator < Bitmap > iterator = bitmapsBySize . iterator ( ) ; Bitmap item ; while ( iterator . hasNext ( ) ) { item = iterator . next ( ) ; if ( null != item && canBePooled ( item ) ) { // Check to see it the item can be used for inBitmap if ( BitmapLruPool . canUseForInBitmap ( item , options ) ) { bitmap = item ; currentSize -= getBitmapSize ( bitmap ) ; // Remove from reusable set so it can't be used again iterator . remove ( ) ; bitmapsByLastUse . remove ( bitmap ) ; break ; } } else { currentSize -= getBitmapSize ( item ) ; // Remove from the set if the reference has been cleared. iterator . remove ( ) ; bitmapsByLastUse . remove ( item ) ; } } } return bitmap ; }
Returns a bitmap from the pool if one is available in the requested size or allocates a new one if a pooled one is not available .