将drawable下的图片转换成bitmap

1、Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.xxx);

2、Resources r = this.getContext().getResources();
Inputstream is = r.openRawResource(R.drawable.xxx);
BitmapDrawable bmpDraw = new BitmapDrawable(is);
Bitmap bmp = bmpDraw.getBitmap();

3、Resources r = this.getContext().getResources();

Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
Bitmap bmp = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );

将drawable下的图片转换成Drawable

Resources resources = mContext.getResources();
Drawable drawable = resources.getDrawable(R.drawable.a);
imageview.setBackground(drawable);

更多相关文章

  1. android 图片处理方法(整理)
  2. 布局文件绘制圆角矩形 背景图片
  3. Android sqlite数据库存取图片信息
  4. Android图片缩放、圆角处理以及倒影特效代码
  5. Android 实现九宫格、点击图片放大全屏浏览等
  6. Android ImageView图片浏览器(ImageView加载sd卡图片资源)的内存溢
  7. android实现点击图片全屏展示效果
  8. android WebView 文字 、图片分开加载

随机推荐

  1. golang判断字符是否存在字符串中
  2. golang用什么编辑器
  3. Golang怎么判断是否为ip
  4. golang怎么判断字符串是否为空
  5. golang怎么判断slice是否为空
  6. go语言环境vim配置详解
  7. Go语言使用正则表达式提取网页文本
  8. golang判断是否目录的方法
  9. golang判断字符是不是字母
  10. 从go语言闭包谈函数式编程