Code example for BitmapFactory.Options

Methods: decodeStream

0
 
    public Bitmap getAlbumArtwork(Context context, long albumId) throws FileNotFoundException {
        final Uri artworkUri = Uri.parse("content://media/external/audio/albumart");
        final Uri uri = ContentUris.withAppendedId(artworkUri, albumId);
        InputStream in = context.getContentResolver().openInputStream(uri);
        Options options = new Options();
        return BitmapFactory.decodeStream(in, null, options);
    } 
 
    public Bitmap getCircularAlbumArtwork(Context context, long albumId) throws FileNotFoundException {
        Bitmap bitmap = getAlbumArtwork(context, albumId);
        if (bitmap == null) {
            return null; 
        } 
        Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_4444);
        BitmapShader shader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
 
        Paint paint = new Paint();
        paint.setShader(shader);
        paint.setAntiAlias(true);