1、从res/drawable/XX.jpg里引用图片资源:
1、 Resources res = getResources(); Bitmap inDrawable= BitmapFactory.decodeResource(res, R.drawable.user_img_grey); userImgButton.setImageBitmap(inDrawable );
2、从本地sd卡的文件路径中使用图片资源:
UserImgPath=Environment.getExternalStorageDirectory().toString()+"/Android/data/org.buptpris.lab.ar" +"/portrait/"+ARUtils.username+".jpg"; Bitmap smallBitmap=ARUtils.loadBitmapFile(UserImgPath,48, 48); userImgButton.setImageBitmap(smallBitmap);