zoom Bitmap To Height - Android Graphics

Android examples for Graphics:Bitmap Zoom

Description

zoom Bitmap To Height

Demo Code


//package com.java2s;

import android.graphics.*;

import android.util.Log;

public class Main {
    private static final String TAG = "BitmapUtil";

    public static Bitmap zoomBitmapToHeight(Bitmap bitmap, int height) {

        Matrix matrix = new Matrix();
        matrix.postScale((float) height / bitmap.getHeight(),
                (float) height / bitmap.getHeight());
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
                bitmap.getHeight(), matrix, true);

    }//  ww w .  j  av a  2s .com
}

Related Tutorials