Android Bitmap Crop cropCenterBitmap(Bitmap bitmap, int newWidth, int newHeight)

Here you can find the source of cropCenterBitmap(Bitmap bitmap, int newWidth, int newHeight)

Description

crop Center Bitmap

Declaration

public static Bitmap cropCenterBitmap(Bitmap bitmap, int newWidth,
            int newHeight) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    public static Bitmap cropCenterBitmap(Bitmap bitmap, int newWidth,
            int newHeight) {
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        if (newWidth >= width || newHeight >= height) {
            return bitmap;
        }/*from   w  w w .java2  s  .  co m*/
        int startX = (width - newWidth) / 2;
        int startY = (height - newHeight) / 2;
        Bitmap result = Bitmap.createBitmap(bitmap, startX, startY,
                newWidth, newHeight);
        bitmap.recycle();
        return result;
    }
}

Related

  1. getTrimmedTop(Bitmap img, int border)
  2. cutImg(File file, int newWidth, int newHeight)
  3. cutStretchImage(Bitmap image, int xsize, int ysize)
  4. cutImg(Bitmap bitmap, int newWidth, int newHeight)
  5. cropCenter(Bitmap bitmap, boolean recycle)
  6. resizeDownAndCropCenter(Bitmap bitmap, int size, boolean recycle)
  7. resizeDownIfTooBig(Bitmap bitmap, int targetSize, boolean recycle)
  8. resizeDownToPixels(Bitmap bitmap, int targetPixels, boolean recycle)
  9. cropImage(Context context, Uri imageuri, Uri tempUri)