is android supports auto scaling of images


Last Updated:

  1. mikethelearner

    mikethelearner New Member This Topic's Starter

    Joined:
    Feb 15, 2010
    Messages:
    4
    Likes Received:
    0
    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

    Joined:
    Aug 10, 2008
    Messages:
    23
    Likes Received:
    7
    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...