private static final String IMAGE_FILE_LOCATION = "file:///sdcard/temp.jpg";//temp file Uri imageUri = Uri.parse(IMAGE_FILE_LOCATION);//The Uri to store the big bitmap
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//action is capture intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, TAKE_BIG_PICTURE);//or TAKE_SMALL_PICTURE
switch
(requestCode) {
case
TAKE_BIG_PICTURE:
Log.d(TAG,
"TAKE_BIG_PICTURE:
data = "
+ data);//it
seems to be null
//TODO
sent to crop
cropImageUri(imageUri,
800,
400,
CROP_BIG_PICTURE);
break;
case
TAKE_SMALL_PICTURE:
Log.i(TAG,
"TAKE_SMALL_PICTURE:
data = "
+ data);
//TODO
sent to crop
cropImageUri(imageUri,
300,
150,
CROP_SMALL_PICTURE);
break;
default:
break;
}
private
void
cropImageUri(Uri uri, int
outputX, int
outputY, int
requestCode){
Intent
intent = new
Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri,
"image/*");
intent.putExtra("crop",
"true");
intent.putExtra("aspectX",
2);
intent.putExtra("aspectY",
1);
intent.putExtra("outputX",
outputX);
intent.putExtra("outputY",
outputY);
intent.putExtra("scale",
true);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
uri);
intent.putExtra("return-data",
false);
intent.putExtra("outputFormat",
Bitmap.CompressFormat.JPEG.toString());
intent.putExtra("noFaceDetection",
true);
//
no face detection
startActivityForResult(intent,
requestCode);
}
switch
(requestCode) {
case
CROP_BIG_PICTURE://from
crop_big_picture
Log.d(TAG,
"CROP_BIG_PICTURE:
data = "
+ data);//it
seems to be null
if(imageUri
!= null){
Bitmap
bitmap = decodeUriAsBitmap(imageUri);
imageView.setImageBitmap(bitmap);
}
break;
case
CROP_SMALL_PICTURE:
if(imageUri
!= null){
Bitmap
bitmap = decodeUriAsBitmap(imageUri);
imageView.setImageBitmap(bitmap);
}else{
Log.e(TAG,
"CROP_SMALL_PICTURE:
data = "
+ data);
}
break;
default:
break;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有