使用ImageView中的Picasso以纵向方向从Firebase中检索图像 [英] Retrieving Images from Firebase in portrait Orientation using Picasso in an ImageView
问题描述
我已经成功地使用 Picasso
以纵向的方式从手机的相册上传图片到firebase的应用程序,但是当我尝试检索某些图片时,当他们改变方向时,可能是当图像尺寸变大时。下面是示例图。
我也使用 Picasso
当从 Firebase
检索图片时,如何在图片不是肖像时自动侦测如 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(); (c).load(imageUri).fit()。(imageSelect);
//imageSelect.setImageURI (imageUri);
$ p $这是从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(){
//重新载入图像...
Picasso.with(c).load(imageUrl).error( R.mipmap.add_btn).placeholder(R.mipmap.add_btn)
.into(imagePost);
}
});
$ b
解决方案如果图片的方向在上传到Firebase之前发生变化,并且在检索之后。
I have successfully made an App which uploads pictures to firebase from the phone's Album in a portrait orientation using Picasso
, but when i try to retrieve some of the pictures , they come when they have changed the orientation, maybe when the image size is bigger. Below is the sample pic.
I use also Picasso
while retrieving the image from Firebase
, How can i be able to make an automatic detection when the image is not portrait to be set portrait without loosing an image quality like Facebook.
Below is the code which selects an image from the Gallery.
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);
}
}
This is the code which Retrieves an image from Firebase to the 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);
}
});
}
解决方案 try check if the orientation of image changed before upload to Firebase and after retrieve it.
这篇关于使用ImageView中的Picasso以纵向方向从Firebase中检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!