Android Bitmap Resize createFitXYBitmap(Bitmap srcBitmap, int dstWidth, int dstHeight, boolean tryRecycleSource)

Here you can find the source of createFitXYBitmap(Bitmap srcBitmap, int dstWidth, int dstHeight, boolean tryRecycleSource)

Description

create Fit XY Bitmap

Declaration

public static Bitmap createFitXYBitmap(Bitmap srcBitmap, int dstWidth,
            int dstHeight, boolean tryRecycleSource) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    public static Bitmap createFitXYBitmap(Bitmap srcBitmap, int dstWidth,
            int dstHeight, boolean tryRecycleSource) {
        if (srcBitmap == null || dstWidth <= 0 || dstHeight <= 0) {
            return srcBitmap;
        }/*from w w w  . j  ava  2  s.  c o  m*/

        Bitmap dstBitmap = srcBitmap;
        try {
            dstBitmap = Bitmap.createScaledBitmap(srcBitmap, dstWidth,
                    dstHeight, true);
            if (dstBitmap != srcBitmap && tryRecycleSource) {
                srcBitmap.recycle();
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return dstBitmap;
    }
}

Related

  1. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  2. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  3. createFitCenterBitmap(Bitmap srcBitmap, int dstWidth, int dstHeight, boolean tryRecycleSource)
  4. getSampledBitmap(String filePath, int reqWidth, int reqHeight)
  5. manageBitmapRotatio(int photoW, int photoH, Bitmap bitMap, int rotation)
  6. readBitmapAutoSize(String filePath, int outWidth, int outHeight)
  7. resize(Bitmap bitmap, int newWidth, int newHeight)