【问题标题】:How to get inputstream from bitmap image file?如何从位图图像文件中获取输入流?
【发布时间】:2011-11-07 05:13:27
【问题描述】:
我正在开发一个联系人应用程序。我想向我的自定义列表视图显示联系人图像。我想从该联系人图像中获取 Inputstream 以写入 sdcard 。我怎样才能得到它?
感谢任何帮助。
【问题讨论】:
标签:
android
bitmap
inputstream
【解决方案1】:
从documentation here逐字复制:
public InputStream openDisplayPhoto(long photoFileId) {
Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
try {
AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
displayPhotoUri, "r");
return fd.createInputStream();
} catch (IOException e) {
return null;
}
}