图片_ _ Bitmap_Drawable_Image?

===== 2 

 

 

==== 1  

b、读取res/drawable目录下的 png或者bmp

Resources r = this.getContext().getResources();
//以数据流的方式读取资源
Inputstream is = r.openRawResource(R.drawable.mm_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);

 

用 Bitmap  bm = BitmapFactory.decodeResource(this.getResources(), R.drawable.splash);
BitmapDrawable  bd = new BitmapDrawable(this.getResources(), bm);
mBtn.setBackgroundDrawable(bd);         来代替  mBtn.setBackgroundResource(R.drawable.splash)。

 

posted on 2016-04-08 00:09  左手指月  阅读(158)  评论(0编辑  收藏  举报