question: static int findBestSampleSize ( int actualWidth , int actualHeight , int desiredWidth , int desiredHeight ) { double wr = ( double ) actualWidth / desiredWidth ; double hr = ( double ) actualHeight / desiredHeight ; double ratio = Math . min ( wr , hr ) ; float n = 1.0f ; while ( ( n * 2 ) <= ratio ) { n *= 2 ; } return ( int ) n ; }
target:  Returns the largest power-of-two divisor for use in downscaling a bitmap that will not result in the scaling past the desired dimensions.