如何解决BitmapFactory.decodeFile() 为现有图像返回 null
我现在面临一个问题。 Why Bitmap.decodeFile() method is returning null? 我尝试了以下建议。 但上述建议对我没有帮助。
代码:
private File createPhotoFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",Locale.getDefault()).format(new Date());
String imageFileName = "IMG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(imageFileName,".png",storageDir);
String mCurrentPhotoPath = image.toString();
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath,bmOptions);
//bitmap = Bitmap.createScaledBitmap(bitmap,parent.getWidth(),parent.getHeight(),true);
Bitmap markedImage = waterMark(bitmap,"your_string",Color.RED,90,true);
File file = new File("path");
OutputStream os = new BufferedOutputStream(new FileOutputStream(String.valueOf(markedImage)));
bitmap.compress(Bitmap.CompressFormat.JPEG,100,os);
os.close();
return file;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。