zoom Bitmap To Width - Android Graphics

Android examples for Graphics:Bitmap Zoom

Description

zoom Bitmap To Width

Demo Code


//package com.java2s;

import android.graphics.*;

import android.util.Log;

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

    public static Bitmap zoomBitmapToWidth(Bitmap bitmap, int width) {

        Matrix matrix = new Matrix();
        matrix.postScale((float) width / bitmap.getWidth(), (float) width
                / bitmap.getWidth());//from  w  ww  .ja  v  a2s  .co  m
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
                bitmap.getHeight(), matrix, true);

    }
}

Related Tutorials