/*
* 裁剪图片
*/
private void cropPhoto() {
Intent intent = new Intent("com.android.camera.action.CROP");
Uri uri = Uri.parse("file://" + picSavePath);
intent.setDataAndType(uri, "image/*");
intent.putExtra("crop", "true");
// intent.putExtra("aspectX", 3);
// intent.putExtra("aspectY", 2);
intent.putExtra("outputX", cropX);
intent.putExtra("outputY", cropY);
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, CROP_PICTURE);
}
/*
* 裁剪图片,
*/
private void cropPhotoAndZoom() {
Intent intent = new Intent("com.android.camera.action.CROP");
Uri uri = Uri.parse("file://" + picSavePath);
intent.setDataAndType(uri, "image/*");
intent.putExtra("crop", "true");
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, CROP_PICTURE_ANDZOOM);
}
/**
* 裁剪后,根据裁剪框的长宽比,同时根据图片的需求缩放尺寸进行缩放
*
* @param path
* @param x
* 原始的需求尺寸width
* @param y
* heiht
* @return
*/
public static Bitmap toBigZoom(String path, float x, float y) {
Log.e("bitmaputil", "path---" + path + "--x--y--" + x + "--" + y);
Bitmap bitmap = BitmapFactory.decodeFile(path);
if (bitmap != null) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
float sx = 0;
float sy = 0;
if ((float) w / h >= 1) {
sx = (float) y / w;
sy = (float) x / h;
Log.e("bitmaputil---", "w/h--->=1");
} else {
sx = (float) x / w;
sy = (float) y / h;
Log.e("bitmaputil---", "w/h---<1");
}
Matrix matrix = new Matrix();
matrix.postScale(sx, sy); // 长和宽放大缩小的比例
Bitmap resizeBmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
Log.e("bitmaputil---", "w---" + resizeBmp.getWidth() + "h--" + resizeBmp.getHeight());
return resizeBmp;
}
return null;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有