code: private static Bitmap loadBitmapOptimized(ImageSource source, int w, int h) throws ImageLoadException {
          int scale = getScaleFactor(source.getImageMetadata(), w, h);
          return loadBitmap(source, scale);
      }
docs: Loading bitmap from ImageSource with limit of amout of pixels
  
  @param source image source
  @param w      min width
  @param h      min height
  @return loaded bitmap
  @throws ImageLoadException if it is unable to load image