Retrieving Images from Firebase in portrait Orientation using Picasso in an ImageView

南楼画角 提交于 2019-12-12 03:04:59

问题


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);
            }
        });

    }

回答1:


Replace it

Picasso.with(c).load(imageUrl).error(R.mipmap.add_btn).fit().centerInside().rotate(90).placeholder(R.mipmap.add_btn)

On this

Picasso.with(c).load(imageUrl).error(R.mipmap.add_btn).fit().centerInside().placeholder(R.mipmap.add_btn)

here too much rotate(90)




回答2:


try check if the orientation of image changed before upload to Firebase and after retrieve it.



来源:https://stackoverflow.com/questions/40336873/retrieving-images-from-firebase-in-portrait-orientation-using-picasso-in-an-imag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!