question: public static int [ ] scaleDownInside ( int inWidth , int inHeight , int maxWidth , int maxHeight ) { int scaledWidth ; int scaledHeight ; if ( inWidth <= maxWidth && inHeight <= maxHeight ) { scaledWidth = inWidth ; scaledHeight = inHeight ; } else { double widthRatio = ( double ) inWidth / ( double ) maxWidth ; double heightRatio = ( double ) inHeight / ( double ) maxHeight ; if ( widthRatio > heightRatio ) { scaledWidth = maxWidth ; scaledHeight = ( int ) Math . round ( ( double ) inHeight / widthRatio ) ; } else { scaledHeight = maxHeight ; scaledWidth = ( int ) Math . round ( ( double ) inWidth / heightRatio ) ; } } return new int [ ] { scaledWidth , scaledHeight } ; }
target:  Returns int[] {scaledWidth, scaledHeight} for dimensions that fit within the given maxWidth, maxHeight at the given inWidth, inHeight aspect ratio.  If the in dimensions fit fully inside the max dimensions, no scaling is applied.  Otherwise, at least one scaled dimension is set to a max dimension, and the other scaled dimension is scaled to fit.