scale Down Bitmap - Android Graphics

Android examples for Graphics:Bitmap Scale

Description

scale Down Bitmap

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Bitmap;

public class Main {
    public static Bitmap scaleDownBitmap(Bitmap photo, int newHeight,
            Context context) {//  w w w  . j a  va2  s.  c  o  m

        final float densityMultiplier = context.getResources()
                .getDisplayMetrics().density;

        int h = (int) (newHeight * densityMultiplier);
        int w = (int) (h * photo.getWidth() / ((double) photo.getHeight()));

        photo = Bitmap.createScaledBitmap(photo, w, h, true);

        return photo;
    }
}

Related Tutorials