1. Check out our companion app, Forums for Android! Download from Google Play

is android supports auto scaling of images

Discussion in 'Application Development' started by mikethelearner, Feb 18, 2010.

  1. mikethelearner

    mikethelearner New Member
    Thread Starter
    5

    Feb 15, 2010
    4
    0
    5
    hai guys,

    i am developing a game. minimum screen resolution that it should support is 240 X 320 for above screen resolutions
    like 320 X 480 etc the images should auto scale. how can i achieve it.
     

    Advertisement

  2. jon21569

    jon21569 Member
    16

    Aug 10, 2008
    23
    7
    16
    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;
    }
     

Share This Page

Loading...