来自 android 中文件的图像
image from a file in android
我正在使用以下代码从图像文件中获取位图。
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile( requestPackage.getPics().get(i), options);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,60,baos)
但它 returns 文件未找到异常,即使文件存在。
这是使用的图像路径"file:/storage/emulated/0/Download/form_message_1.jpg"
从该路径中删除 'file:',然后重试。
我正在使用以下代码从图像文件中获取位图。
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile( requestPackage.getPics().get(i), options);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,60,baos)
但它 returns 文件未找到异常,即使文件存在。
这是使用的图像路径"file:/storage/emulated/0/Download/form_message_1.jpg"
从该路径中删除 'file:',然后重试。