Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Intent crop = new Intent("com.android.camera.action.CROP");
- crop.setDataAndType(outputFileUri, "image/*");
- crop.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- crop.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- crop.putExtra("crop", "true");
- crop.putExtra("aspectX", 139);
- crop.putExtra("aspectY", 185);
- crop.putExtra("scale", true);
- crop.putExtra("return-data", true);
- startActivityForResult(crop, CROP_AFTER_CAMERA);
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == PICK_FROM_CAMERA && resultCode == RESULT_OK) {
- if (outputFileUri != null) {
- crop_image();
- }
- }
- else if (requestCode == EDIT_CROPPED_IMAGE) {
- }
- else if (requestCode == CROP_AFTER_CAMERA) {
- if (data != null) {
- Bundle bundle = data.getExtras();
- Bitmap cropBit = bundle.getParcelable("data");
- imgView.setImageBitmap(cropBit);
- saveBitmap(cropBit);
- }
- }
- else if (resultCode == RESULT_CANCELED) {
- Provider.deleteFile(getBaseContext(), outputFileUri);
- }
- }
- OutputStream out = null;
- File image_file = new File(targetFolder + filename);
- try {
- image_file.createNewFile();
- out = new FileOutputStream(image_file);
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement