How do I change Drawable to Bitmap?

Asked 1 years ago, Updated 1 years ago, 92 views

I want to use the device wallpaper as Drawable, but when I looked at the wallpaper function, it only works as Bitmap. So I can't use Wallpaper Manager, so can I change Drawable to Bitmap?

android bitmap wallpaper drawable

2022-09-21 20:21

1 Answers

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

This is turning Drawable into a bitmap.

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

This is how to download an image from the web as a bitmap


2022-09-21 20:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.