Android 将drawable下的图片转换成bitmap、Drawable
16lz
2021-01-23
将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);
更多相关文章
- android 图片处理方法(整理)
- 布局文件绘制圆角矩形 背景图片
- Android sqlite数据库存取图片信息
- Android图片缩放、圆角处理以及倒影特效代码
- Android 实现九宫格、点击图片放大全屏浏览等
- Android ImageView图片浏览器(ImageView加载sd卡图片资源)的内存溢
- android实现点击图片全屏展示效果
- android WebView 文字 、图片分开加载