Home Load image from internal memory
Reply: 1

Load image from internal memory

shasha
1#
shasha Published in 2018-01-12 16:21:36Z

i'm having problem in loading image coming from the internal storage of my android phone. I want to load the image and use it for grabcut segmentation. I tried using this code

  File file = new File(getExternalFilesDir(null).getAbsolutePath()+"pic.jpg");
     ImageView iv = (ImageView) findViewById(R.id.imagePreview);  
    Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());

But everytime I run the app on my phone the application suddenly stopped. Can I ask for help and know what's wrong in my code? Thank you so much.

Alex Gimondi
2#
Alex Gimondi Reply to 2018-01-12 16:41:40Z

What is the error you get? Find out in the debug. I tried to run your code and the path I get is: /storage/emulated/0/Android/data/.../filespic.jpg so I would say try to change

+"pic.jpg");

in

+"/pic.jpg");

and

iv.setImageBitmap(bitmap);

to show image.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.323631 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO