android 获取Bitmap 的两种方法
这里我直接贴代码了。
第一种方法
//得到Resources对象Resources r = this.getContext().getResources();//以数据流的方式读取资源Inputstream is = r.openRawResource(R.drawable.my_background_image);BitmapDrawable bmpDraw = new BitmapDrawable(is);Bitmap bmp = bmpDraw.getBitmap();
InputStream is = getResources().openRawResource(R.drawable.icon); Bitmap mBitmap = BitmapFactory.decodeStream(is); Paint mPaint = new Paint(); canvas.drawBitmap(mBitmap, 40, 40, mPaint);