I am facing an issue now. Why Bitmap.decodeFile() method is returning null? I tried with the following advice. but the above advice doesn’t help me.
sharing my codes here:
returning bitmap = null, help me to fix this issue.
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, 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; }
Recent Comments