/** * here we detect the version, because the new version's way is different with the old . * * @param activity * @param uri */ public static void CropPhoto(final Activity activity, Uri uri) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 120); intent.putExtra("outputY", 120); intent.putExtra("crop", "true"); intent.putExtra("scale", true); intent.putExtra("scaleUpIfNeeded", true); intent.putExtra("return-data", true); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { Uri selectedImage = uri; String imagePath = PictureHelper.getPath(activity, selectedImage); // 获取图片的绝对路径 Uri newUri = Uri.parse("file:///" + imagePath); // 将绝对路径转换为URL intent.setDataAndType(newUri, "image/*"); activity.startActivityForResult(intent, REQUEST_CODE_FROM_CROP); // 4.4版本 } else { intent.setDataAndType(uri, "image/*"); activity.startActivityForResult(intent, REQUEST_CODE_FROM_CROP); // 4.4以下版本 } }
public Bitmap getPictureBitmap(StringProperty pictureProperty) { String value = getValue(pictureProperty); return PictureHelper.getPictureBitmap(value); }
public String getPictureUrl(StringProperty pictureProperty, String size) { String value = getValue(pictureProperty); return PictureHelper.getPictureUrl(value, size); }