android--获取资源文件 r.drawable中的图片转换为drawable、bitmap
1、Resources resources = mContext.getResources();Drawable drawable = resources.getDrawable(R.drawable.a);imageview.setBackground(drawable);2、Resources r = this.getContext().getResources();Inpu...
1、
Resources resources = mContext.getResources();
Drawable drawable = resources.getDrawable(R.drawable.a);
imageview.setBackground(drawable);
2、
Resources r = this.getContext().getResources();
Inputstream is = r.openRawResource(R.drawable.my_background_image);
BitmapDrawable bmpDraw = new BitmapDrawable(is);
Bitmap bmp = bmpDraw.getBitmap();
3、
Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
Bitmap newb = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );
4、
InputStream is = getResources().openRawResource(R.drawable.icon);
Bitmap mBitmap = BitmapFactory.decodeStream(is);
————————————————
版权声明:本文为CSDN博主「丿灬安之若死」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mp624183768/article/details/78179472
更多推荐
所有评论(0)