Here you can find the source of initBitmapFactoryOptions( BitmapFactory.Options bitmapOptions, int maxWidth, int maxHeight)
Parameter | Description |
---|---|
bitmapOptions | bitmap options |
maxWidth | max width |
maxHeight | max height |
public static boolean initBitmapFactoryOptions( BitmapFactory.Options bitmapOptions, int maxWidth, int maxHeight)
//package com.java2s; import android.graphics.BitmapFactory; public class Main { /**//ww w . j a v a 2 s. c o m * @param bitmapOptions bitmap options * @param maxWidth max width * @param maxHeight max height * @return true if success */ public static boolean initBitmapFactoryOptions( BitmapFactory.Options bitmapOptions, int maxWidth, int maxHeight) { if (bitmapOptions.inJustDecodeBounds && bitmapOptions.outHeight > 0 && bitmapOptions.outWidth > 0) { if (bitmapOptions.outWidth > (maxWidth << 1) || bitmapOptions.outHeight > (maxHeight << 1)) { bitmapOptions.inSampleSize = Math.max( bitmapOptions.outWidth / maxWidth, bitmapOptions.outHeight / maxHeight); } bitmapOptions.inJustDecodeBounds = false; return true; } return false; } }