将可绘制资源图像转换为位图 [英] converting drawable resource image into bitmap

查看:19
本文介绍了将可绘制资源图像转换为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用采用位图图像的 Notification.Builder.setLargeIcon(bitmap).我的可绘制文件夹中有要使用的图像,那么如何将其转换为位图?

I am trying to use the Notification.Builder.setLargeIcon(bitmap) that takes a bitmap image. I have the image I want to use in my drawable folder so how do I convert that to bitmap?

推荐答案

你可能是说 Notification.Builder.setLargeIcon(Bitmap) 吧?:)

You probably mean Notification.Builder.setLargeIcon(Bitmap), right? :)

Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.large_icon);
notBuilder.setLargeIcon(largeIcon);

这是将资源图像转换为 Android Bitmaps 的好方法.

This is a great method of converting resource images into Android Bitmaps.

这篇关于将可绘制资源图像转换为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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