Skip to content

Instantly share code, notes, and snippets.

@brianhsu
Created September 16, 2015 09:10
Show Gist options
  • Select an option

  • Save brianhsu/8b2f3ec0599c9cb95589 to your computer and use it in GitHub Desktop.

Select an option

Save brianhsu/8b2f3ec0599c9cb95589 to your computer and use it in GitHub Desktop.
val ResizeFactor(originWidth, originHeight, factor) = ImageSampleFactor(fixedURL, thumbnailSize, thumbnailSize)
val options = new BitmapFactory.Options
options.inSampleSize = factor
if (originWidth <= 48 || originHeight <= 48) {
options.inDensity = 160
options.inScaled = false
options.inTargetDensity = 160
}
val imgStream = new URL(fixedURL).openConnection().getInputStream
val imgBitmap = BitmapFactory.decodeStream(imgStream, null, options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment