Convert a File Object to Bitmap
You should be able to use BitmapFactory
:
File mSaveBit; // Your image fileString filePath = mSaveBit.getPath(); Bitmap bitmap = BitmapFactory.decodeFile(filePath);mImageView.setImageBitmap(bitmap);
Define File
String fileName = "/myImage.jpg";File file = new File(fileName);
get Bitmap of Image
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
Set Bitmap to ImageView
myImageView.setImageBitmap(bitmap);
You can use this function to get Bitmap from file path
fun getBitmap(filePath:String):Bitmap?{ var bitmap:Bitmap?=null try{ var f:File = File(path) var options = BitmapFactory.Options() options.inPreferredConfig = Bitmap.Config.ARGB_8888 bitmap = BitmapFactory.decodeStream(FileInputStream(f),null,options) }catch (e:Exception){ } return bitmap}