Green_qaue
Green_qaue

Reputation: 3661

Scaling bitmaps for each resolution

Is there any method that gets the phones resolution (or dp) and scales bitmaps accordingly? I have all my images in xhdpi folder and at the moment they do not scale the way they should.

I want an efficiant and memory-friendly method that can do the scaling automatically. If not, what is the next best thing? completely new area for me. So any tutorial-link is also appriciated.

this is what I use to load bitmaps atm:

public Bitmap loadBitmap(int resourceID) {
    Options options = new BitmapFactory.Options();
    options.inScaled = true;
    options.inPreferredConfig = Bitmap.Config.RGB_565;
    Bitmap tempBmp = null;
    try {
        tempBmp = BitmapFactory.decodeResource(getResources(), resourceID,
                options);
    } catch (OutOfMemoryError e) {

    } catch (Error e) {

    }
    return tempBmp;
}

Upvotes: 0

Views: 754

Answers (0)

Related Questions