rookieding 2011-10-21
protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Bundle extras = data.getExtras(); Bitmap b = (Bitmap) extras.get("data"); // img.setImageBitmap(b); if (b != null) { try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(android.os.Environment .getExternalStorageDirectory() + "/a.jpeg")); b.compress(CompressFormat.JPEG, 75, bos); bos.flush(); bos.close(); } catch (Exception e) { e.printStackTrace(); } } }
Feature: 点击选择拍照或者打开相册,选取图片进行裁剪最后设置为圆形头像。Problem: 拍好照片,点击裁剪,弹Toast“无法加载此图片”。Solution: 在裁剪的class里加两行代码