[英]How can I edit a photo taken via the camera in my application?
In my application I use the camera to take photos. 在我的应用程序中,我使用相机拍照。
I use this code to start the camera Activity: 我使用以下代码启动摄像头活动:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
timeStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
File file = new File(directory, timeStamp+".png"); //name
Uri outputFileUri1 = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri1);
startActivityForResult(intent, CAMERA_RESULT);
This code is working, but how can I edit the preview image (crop, rotate,...) before my main Activity gets the data in onActivityResult()
? 这段代码有效,但是如何在我的主Activity在onActivityResult()
获取数据之前编辑预览图像(裁剪,旋转等onActivityResult()
?
Or how can I start the photo editor for my image from my application? 或者如何从应用程序中为图像启动照片编辑器?
You should create a Bitmap object out of your image, then you could manipulate it. 您应该在图像之外创建一个Bitmap对象,然后可以对其进行操作。
String fooFile = "PATH TO FILE";
Bitmap bmp = BitmapFactory.decodeFile(fooFile);
here is a crop example . 这是一个庄稼的例子 。 for more examples just Google for 'Bitmap manipulation android' 有关更多示例,请参见Google的“位图操作android”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.