public static int determineSampleSize(ImageRequest imageRequest,EncodedImage encodedImage){
  if (!EncodedImage.isMetaDataAvailable(encodedImage)) {
    return DEFAULT_SAMPLE_SIZE;
  }
  float ratio=determineDownsampleRatio(imageRequest,encodedImage);
  int sampleSize;
  if (encodedImage.getImageFormat() == ImageFormat.JPEG) {
    sampleSize=ratioToSampleSizeJPEG(ratio);
  }
 else {
    sampleSize=ratioToSampleSize(ratio);
  }
  int maxDimension=Math.max(encodedImage.getHeight(),encodedImage.getWidth());
  while (maxDimension / sampleSize > MAX_BITMAP_SIZE) {
    if (encodedImage.getImageFormat() == ImageFormat.JPEG) {
      sampleSize*=2;
    }
 else {
      sampleSize++;
    }
  }
  return sampleSize;
}

public static int determineSampleSize ( ImageRequest imageRequest , EncodedImage encodedImage ) { if ( ! EncodedImage . isMetaDataAvailable ( encodedImage ) ) { return DEFAULT_SAMPLE_SIZE ; } float ratio = determineDownsampleRatio ( imageRequest , encodedImage ) ; int sampleSize ; if ( encodedImage . getImageFormat ( ) == ImageFormat . JPEG ) { sampleSize = ratioToSampleSizeJPEG ( ratio ) ; } else { sampleSize = ratioToSampleSize ( ratio ) ; } int maxDimension = Math . max ( encodedImage . getHeight ( ) , encodedImage . getWidth ( ) ) ; while ( maxDimension / sampleSize > MAX_BITMAP_SIZE ) { if ( encodedImage . getImageFormat ( ) == ImageFormat . JPEG ) { sampleSize *= 2 ; } else { sampleSize ++ ; } } return sampleSize ; }
get the factor between the dimensions of the encodedimage ( actual image ) and the ones of the imagerequest ( requested size ) .
