Code example for BitmapFactory.Options

Methods: decodeByteArray

0
		mDisplayHeight = displayMetrics.heightPixels;
		mDisplayWidth = displayMetrics.widthPixels;
	} 
 
	private Options createDecodeOptions() {
		Options options = new BitmapFactory.Options();
		options.inDither = false;
		options.inPurgeable = true;
		options.inInputShareable = true;
		options.inTempStorage = new byte[32 * 1024];
		options.inJustDecodeBounds = true;
		return options;
	} 
 
	public Drawable getDrawableFromResource(int resourceId, int desiredWidth, int desiredHeight) {
		return new BitmapDrawable(mResources, decodeFromResource(resourceId, desiredWidth, desiredHeight));
	} 
 
	public Drawable getDrawableFromFilePath(String filePath, int desiredWidth, int desiredHeight) {
		return new BitmapDrawable(mResources, decodeFromFilePath(filePath, desiredWidth, desiredHeight));
	} 
 
	public Bitmap decodeFromResource(int resourceId, int desiredWidth, int desiredHeight) {
		Options options = createDecodeOptions();
		BitmapFactory.decodeResource(mResources, resourceId, options);
		onCalculateOptionsSampleSize(options, desiredWidth, desiredHeight);
		return BitmapFactory.decodeResource(mResources, resourceId, options);
	} 
 
	public Bitmap decodeFromFilePath(String filePath, int desiredWidth, int desiredHeight) {
		Options options = createDecodeOptions();
		BitmapFactory.decodeFile(filePath, options);
		onCalculateOptionsSampleSize(options, desiredWidth, desiredHeight);
		return BitmapFactory.decodeFile(filePath, options);
	} 
 
	public Bitmap decodeFromByteArray(byte[] data, int desiredWidth, int desiredHeight) {
		Options options = createDecodeOptions();
		BitmapFactory.decodeByteArray(data, 0, data.length, options);
		onCalculateOptionsSampleSize(options, desiredWidth, desiredHeight);
		return BitmapFactory.decodeByteArray(data, 0, data.length, options);
	} 
 
	public Bitmap decodeFromStream(InputStream input, int desiredWidth, int desiredHeight) {
		ByteArrayOutputStream out = null;
		try {