• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps is android supports auto scaling of images

This is not auto detection, but I wrote a small function that returns a scaled bitmap based on a max width and height.

private Bitmap resizeImage( final Bitmap image, final int maxWidth, final int maxHeight ) {
final Bitmap resizedImage;
int imageHeight = image.getHeight();
if ( imageHeight > maxHeight )
imageHeight = maxHeight;
int imageWidth = (imageHeight*image.getWidth()) / image.getHeight();
if ( imageWidth > maxWidth ) {
imageWidth = maxWidth;
imageHeight = (imageWidth*image.getHeight()) / image.getWidth();
}
resizedImage = Bitmap.createScaledBitmap( image, imageWidth, imageHeight, true);
return resizedImage;
}
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones