get Scale Bitmap - Android Graphics

Android examples for Graphics:Bitmap Scale

Description

get Scale Bitmap

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Matrix;

public class Main {

    public static Bitmap getScaleBitmap(Bitmap mBitmap, float scaleRatio) {
        int width = mBitmap.getWidth();
        int height = mBitmap.getHeight();

        Matrix matrix = new Matrix();
        matrix.postScale(scaleRatio, scaleRatio);
        Bitmap mScaleBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width,
                height, matrix, true);/*from w  w w  .  jav  a2 s.  c  om*/

        return mScaleBitmap;
    }
}

Related Tutorials