BitmapFactory.decodeFile() 为现有图像返回 null

问题描述

我现在面临一个问题。 Why Bitmap.decodeFile() method is returning null? 我尝试了以下建议。 但上述建议对我没有帮助。

For directories reference

代码

    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 (将#修改为@)