Created
June 7, 2014 20:46
-
-
Save nalitzis/bad4c1e89a0ec185fb0d to your computer and use it in GitHub Desktop.
Subsampling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void subSampleImage(int powerOf2) { | |
if(powerOf2 < 1 || powerOf2 > 8) { | |
Log.e(TAG, "trying to apply upscale or excessive downscale: "+powerOf2); | |
return; | |
} | |
final Resources res = getActivity().getResources(); | |
final BitmapFactory.Options options = new BitmapFactory.Options(); | |
options.inJustDecodeBounds = false; | |
options.inSampleSize = powerOf2; | |
final Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.brasil, options); | |
final BitmapDrawable bmpDrawable = new BitmapDrawable(res, bmp); | |
mRootLayout.setBackground(bmpDrawable); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment