Bitmap获取文件路径并显示及获取图片属性
?
private ImageView mImageView;private String filePath = "/mnt/sdcard/DCIM/Camera/abc.jpg";public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.bitmap);mImageView = (ImageView) findViewById(R.id.imageView1);File f = new File(filePath);if (f.exists()) { /* 产生Bitmap对象,并放入mImageView中 */Bitmap bm = BitmapFactory.decodeFile(filePath);mImageView.setImageBitmap(bm);} else {toast("文件不存在");}}public void toast(String str) {Toast.makeText(BitmapImage.this, str, Toast.LENGTH_LONG).show();}获取图片宽高
Bitmap myBmp = BitmapFactory.decodeResource (getResources(), R.drawable.baby); /*透过Bitmap对象的getHight与getWidth来取得图片宽高*/ int intHeight = myBmp.getHeight(); int intWidth = myBmp.getWidth();?