yijidemomo 2012-09-21 02:40 采纳率: 100%
浏览 6878
已采纳

如何把一个图片转换成位图?

我想要设置一个图片成为手机的壁纸,但是所有的壁纸功能都只接受位图。我不能使用WallpaperManager 因为我的系统是2.1之前的。
而且我的壁纸是从网上下载的,不在R.drawable里边。

  • 写回答

4条回答

  • 漫随风起 2012-09-21 03:37
    关注

    这些代码可能有用

    Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
                                               R.drawable.icon_resource);
    

    这是一个图像是下载的版本

    String name = c.getString(str_url);
    URL url_value = new URL(name);
    ImageView profile = (ImageView)v.findViewById(R.id.vdo_icon);
    if (profile != null) {
        Bitmap mIcon1 =
            BitmapFactory.decodeStream(url_value.openConnection().getInputStream());
        profile.setImageBitmap(mIcon1);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?