Mithilesh Izardar
Mithilesh Izardar

Reputation: 2207

getting the image in bitmap but returning black pixels only

I am tried to set the image bitmap it was showing black pixels and i also tried Image URI but again setting black pixels But when i debugged it , the bitmap and uri image are getting the correct image but both the method are not able to set it in imageview.

`ImageView imageView = (ImageView) rootView.findViewById(R.id.imagef);
    try
    {
        String profileImagePath = Environment.getExternalStorageDirectory().toString() + "/MYFolder/"+ Configuration.empcode+".jpg";
        File profilepath = new File(profileImagePath);
        if(profilepath.exists())
        {

            //need to resolve
            Bitmap bmp = BitmapFactory.decodeFile(profileImagePath);

            Uri uri = Uri.fromFile(new File(profileImagePath));
//                imageView.setImageBitmap(bmp);
            imageView.setImageURI(uri);
        }
    }
    catch(Exception e)
    {
        Log.d("Profile Image Exception", e.toString());
    }
`

see the image here

the bitmap value and imageview value

Upvotes: 0

Views: 593

Answers (2)

Amna Mirza
Amna Mirza

Reputation: 703

ImageView imageView = (ImageView) rootView.findViewById(R.id.imagef);
String profileImagePath = Environment.getExternalStorageDirectory().toString() + "/MYFolder/"+ Configuration.empcode+".jpg";
File profilepath = new File(profileImagePath);
Picasso.with(activity_or_fragment_context).load(profilePath).placeholder(R.drawable.any_place_holder_png_file).fit().centerCrop().into(imageView);

Upvotes: 2

Nongthonbam Tonthoi
Nongthonbam Tonthoi

Reputation: 12953

You could use Picasso:

    String profileImagePath = Environment.getExternalStorageDirectory().toString() + "/MYFolder/"+ Configuration.empcode+".jpg";
    File profilepath = new File(profileImagePath);
    Picasso.with(yourActivityContext).load(profilepath).into(imageView);

Upvotes: 1

Related Questions