获取位图中的图像但仅返回黑色像素
getting the image in bitmap but returning black pixels only
我试图设置它显示黑色像素的图像位图,我也尝试过图像 URI,但再次设置黑色像素但是当我调试它时,位图和 uri 图像正在获得正确的图像,但两种方法都是无法在 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());
}
`
在此处查看图片
你可以使用毕加索:
String profileImagePath = Environment.getExternalStorageDirectory().toString() + "/MYFolder/"+ Configuration.empcode+".jpg";
File profilepath = new File(profileImagePath);
Picasso.with(yourActivityContext).load(profilepath).into(imageView);
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);
我试图设置它显示黑色像素的图像位图,我也尝试过图像 URI,但再次设置黑色像素但是当我调试它时,位图和 uri 图像正在获得正确的图像,但两种方法都是无法在 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());
}
`
在此处查看图片
你可以使用毕加索:
String profileImagePath = Environment.getExternalStorageDirectory().toString() + "/MYFolder/"+ Configuration.empcode+".jpg";
File profilepath = new File(profileImagePath);
Picasso.with(yourActivityContext).load(profilepath).into(imageView);
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);