question: public static Bitmap scaleFit ( Bitmap src , int maxW , int maxH ) { float ratio = Math . min ( maxW / ( float ) src . getWidth ( ) , maxH / ( float ) src . getHeight ( ) ) ; int newW = ( int ) ( src . getWidth ( ) * ratio ) ; int newH = ( int ) ( src . getHeight ( ) * ratio ) ; return scale ( src , newW , newH ) ; }
target:  Scaling bitmap to fit required sizes. Method keep aspect ratio.