从uri检索位图 [英] Retrieve bitmap from uri

查看:84
本文介绍了从uri检索位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加入了通过myApp共享"选项.我在接收活动类中插入了以下代码.

I have included 'share via myApp' option. I inserted following code in the receiving activity class.

    // Get the intent that started this activity
    Intent intent = getIntent();
    Uri data = intent.getData();

    // Figure out what to do based on the intent type
    if (intent.getType().indexOf("image/") != -1) {
        // Handle intents with image data ...
}

检索位图图像的下一步是什么.

What is the next step to retrieve bitmap image.

推荐答案

您已经获得了Uri.现在,您必须在getBitmap()中传递该Uri以获得位图并使用该位图.

As you have already get the Uri. Now you have to pass that Uri in getBitmap() to get bitmap and use that bitmap.

Uri imageUri = intent.getData();
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),imageUri);
Imageview my_img_view = (Imageview ) findViewById (R.id.my_img_view);
my_img_view.setImageBitmap(bitmap);

这篇关于从uri检索位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆