美文网首页
BitmapFactory 加载图片的方式

BitmapFactory 加载图片的方式

作者: 沈溺_16e5 | 来源:发表于2019-03-22 17:43 被阅读0次
// 加载 Android Studio 中的图片资源时 
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bb);

// 加载SD卡的图片时   string:图片在SD卡的路径
Uri imageUri= Uri.fromFile(new File(string));

Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));

Android 常用的 Drawable 和 Bitmap 之间的转化方法

相关文章

网友评论

      本文标题:BitmapFactory 加载图片的方式

      本文链接:https://www.haomeiwen.com/subject/zlirvqtx.html