Code example for BitmapFactory.Options

Methods: decodeByteArray

0
		// 注意,存储的时候,也做了压缩处理,@see PictureUtil.storePicture(mBitmap, fName); 
		// 所以,之前mkt360一共用了两次压缩。 
		byte[] mdata = PictureUtil.Bitmap2Bytes(mBitmap);
 
		// 获取宽度缩放比例 
		BitmapFactory.Options mOptions = new Options();
		mOptions.inJustDecodeBounds = true;// 当inJustDecodeBounds设成true时,bitmap并不加载到内存
		int scale_ratio = (int) (width / (float) STANDARD_WIDTH);
		LogUtils.logi(TAG, "ratio is - " + scale_ratio);
		if (scale_ratio <= 0)
			scale_ratio = 1;
		mOptions.inSampleSize = scale_ratio;
		mOptions.inJustDecodeBounds = false;
 
		// 3,这里再通过decodeByteArray将之前的bytes转换成bitmap 
		mBitmap = BitmapFactory.decodeByteArray(mdata, 0, mdata.length,
				mOptions);
		if (mBitmap == null) {
			LogUtils.logi(TAG, "bm is null");
			return null; 
		}