Created
January 24, 2015 15:32
-
-
Save juliomarcos/2abcfefb3d4a1d03eade to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.io.FileNotFoundException; | |
import android.content.Context; | |
import android.content.res.AssetFileDescriptor; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.net.Uri; | |
public class MediaUtils { | |
public static Bitmap getSampledBitmap(Context ctx, Uri uri) throws FileNotFoundException { | |
BitmapFactory.Options options = new BitmapFactory.Options(); | |
options.inSampleSize = 4; | |
AssetFileDescriptor fileDescriptor = ctx.getContentResolver().openAssetFileDescriptor(uri, "r"); | |
return BitmapFactory.decodeFileDescriptor(fileDescriptor.getFileDescriptor(), null, options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment