【发布时间】:2017-03-13 05:21:00
【问题描述】:
我已经成功制作了一个应用程序,它使用Picasso 将手机相册中的图片以纵向方向上传到 firebase,但是当我尝试检索一些图片时,它们会在它们改变方向时出现,也许是当图像尺寸更大。下面是示例图片。
我在从Firebase 检索图像时也使用Picasso,当图像不是肖像时,我如何能够进行自动检测以设置为肖像,而不会丢失像 Facebook 这样的图像质量强>。
以下是从图库中选择图像的代码。
imageSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/");
startActivityForResult(galleryIntent, GALLERY_REQUEST);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == GALLERY_REQUEST && resultCode == RESULT_OK) {
imageUri = data.getData();
Picasso.with(c).load(imageUri).fit().into(imageSelect);
//imageSelect.setImageURI(imageUri);
}
}
这是从 Firebase 检索图像到 RecyclerView 的代码
public void setImage(final Context c,final String imageUrl){
//
Picasso.with(c).load(imageUrl).error(R.mipmap.add_btn).fit().centerInside().rotate(90).placeholder(R.mipmap.add_btn)
.networkPolicy(NetworkPolicy.OFFLINE).into(imagePost, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError() {
//Reloading an image again ...
Picasso.with(c).load(imageUrl).error(R.mipmap.add_btn).placeholder(R.mipmap.add_btn)
.into(imagePost);
}
});
}
【问题讨论】:
标签: android image firebase picasso firebase-storage