【问题标题】:Retrieving Images from Firebase in portrait Orientation using Picasso in an ImageView在 ImageView 中使用 Picasso 以纵向方向从 Firebase 检索图像
【发布时间】: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


    【解决方案1】:

    替换它

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

    关于这个

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

    这里太多了rotate(90)

    【讨论】:

    • 您好@ANDRO 感谢您的回复,但是当我删除rotate(90) 时,这些图像很好,但其他图像在肖像中发生了变化,现在问题是当我从相册中选择图像时进入 imageView 它以纵向方式很好地显示,但是当我将其上传到 Firebase 并将其取回时,一些图像会改变它们的方向,而其他图像则保持纵向。我没有办法自动检查可能使用Picasso帮助改变方向的图像
    • 正常方向的 Firebase 图像?
    • 是的,但是看起来当图像很大时,它会在方向改变时出现,如果我可能会问,有没有一种方法可以在不损失质量的情况下调整所有图像的大小,我认为这可能会解决问题
    • 奇怪。但毕加索图书馆本身不能改变方向。也许问题出在您的代码或 Firebase 中
    【解决方案2】:

    尝试在上传到 Firebase 之前和检索之后检查图像的方向是否发生了变化。

    【讨论】:

      猜你喜欢
      • 2020-04-22
      • 2016-07-18
      • 2017-06-01
      • 2019-07-24
      • 2012-09-25
      • 1970-01-01
      • 2012-03-11
      • 1970-01-01
      相关资源
      最近更新 更多