@ Override protected int selectResolution ( int widthTexture , int heightTexture , Size [ ] resolutions ) { // just wanted to make sure this has been cleaned up timeOfLastUpdated = 0 ; // select the resolution here int bestIndex = - 1 ; double bestAspect = Double . MAX_VALUE ; double bestArea = 0 ; for ( int i = 0 ; i < resolutions . length ; i ++ ) { Size s = resolutions [ i ] ; int width = s . getWidth ( ) ; int height = s . getHeight ( ) ; double aspectScore = Math . abs ( width * height - targetResolution ) ; if ( aspectScore < bestAspect ) { bestIndex = i ; bestAspect = aspectScore ; bestArea = width * height ; } else if ( Math . abs ( aspectScore - bestArea ) <= 1e-8 ) { bestIndex = i ; double area = width * height ; if ( area > bestArea ) { bestArea = area ; } } } return bestIndex ; }
Selects a resolution which has the number of pixels closest to the requested value