Android:使用相机拍摄照片并使用毕加索显示

问题描述 投票:-1回答:1

在Android上,我需要用相机拍摄照片,然后用毕加索将其绘制在ImageView上。

仅使用位图,我就可以使用

Bitmap bitmap = (Bitmap)data.getExtras().get("data");
contactImg.setImageBitmap(bitmap);

毕加索需要一个Uri或路径或文件进行绘制,但是摄影机意图的结果无法为我提供任何帮助。那我怎么用毕加索画呢?

我已经看到一些相关的答案,您可以使用intent.putExtra(MediaStore.EXTRA_OUTPUT, URI);来为意图提供一个路径,因此您可能可以使用该路径通过毕加索进行绘制。但是我们不希望将照片保存在本地。我们只希望将其保留在片段中,将其显示给用户,然后将其上传到服务器上。应该如何处理?

android imageview android-drawable picasso android-bitmap
1个回答
0
投票

您不能将位图用于Picasso的加载方法。您只能使用uri , file , url pathint resource id.

但是您可以使用Glide库,如下所示通过使用.asBitmap()来调用.load()

GlideApp.with(itemView.getContext())
        .asBitmap()
        .load(data.getImageUrl())
        .into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {}
            });
        }
© www.soinside.com 2019 - 2024. All rights reserved.