Android Bitmap Scale scaleToFit(Bitmap bm, float width_Ratio, float height_Ratio)

Here you can find the source of scaleToFit(Bitmap bm, float width_Ratio, float height_Ratio)

Description

scale To Fit

Declaration

public static Bitmap scaleToFit(Bitmap bm, float width_Ratio,
            float height_Ratio) 

Method Source Code


import android.graphics.Bitmap;

import android.graphics.Matrix;

public class Main {
    public static Bitmap scaleToFit(Bitmap bm, float width_Ratio,
            float height_Ratio) {
        int width = bm.getWidth(); 
        int height = bm.getHeight(); 
        Matrix matrix = new Matrix();
        matrix.postScale((float) width_Ratio, (float) height_Ratio);
        Bitmap bmResult = Bitmap.createBitmap(bm, 0, 0, width, height,
                matrix, true);//from  ww w .j  a  v a2  s  .  co m
        return bmResult; 
    }
}

Related

  1. scaleClipBitmapByCircle(Bitmap src, int nRadius, float fStrokeWidth)
  2. getScaledImageFromUri(Activity activity, Uri uri, int size)
  3. imageScale(Bitmap bitmap, int dst_w, int dst_h)
  4. scaleBitmap(Bitmap bitmap, float scale)
  5. scaleBitmapDown(Bitmap bitmap)
  6. stretchImage(Bitmap image, float xscale, float yscale)
  7. stretchImage(Bitmap image, int xsize, int ysize)
  8. zoomImg(Bitmap bm, int newWidth, int newHeight)
  9. getSmallBitmap(String filePath)