从图库中选择机器人当裁剪图像 [英] Crop an image when selected from gallery in android

查看:153
本文介绍了从图库中选择机器人当裁剪图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要裁剪图像在我的应用程序时,它是从图库中选择。 也就是说,如果我启动了画廊,并选择一个图像裁剪窗口应该来的时候,我们选择iPhone的图像等。是否有可能在Android的。

I want to crop an image in my application when it is selected from gallery. i.e if I launch the gallery and select an image the cropping window should come like when we select an image from iPhone. Is it possible in Android.

我发现了一个教程裁剪图像在Android中,但不显得我想要的方式。

I found one tutorial for cropping the image in android, but dont seem the way I wanted.

<一个href="http://www.$c$crzheaven.com/2011/03/15/crop-an-image-in-android/">http://www.$c$crzheaven.com/2011/03/15/crop-an-image-in-android/

推荐答案

是的,它是可能的作物图像中的Andr​​oid使用 com.android.camera.action.CROP 。采摘图像的URL后,从gallery.you将开始裁剪编辑为:

Yes it's possible to crop image in android by using com.android.camera.action.CROP. after picking image url from gallery.you will start Crop Editor as:

Intent intent = new Intent("com.android.camera.action.CROP");  
intent.setClassName("com.android.camera", "com.android.camera.CropImage");  
File file = new File(filePath);  
Uri uri = Uri.fromFile(file);  
intent.setData(uri);  
intent.putExtra("crop", "true");  
intent.putExtra("aspectX", 1);  
intent.putExtra("aspectY", 1);  
intent.putExtra("outputX", 96);  
intent.putExtra("outputY", 96);  
intent.putExtra("noFaceDetection", true);  
intent.putExtra("return-data", true);                                  
startActivityForResult(intent, REQUEST_CROP_ICON);

在图片选择活动收益将被选中保存contents.in onActivityResult

When the picture select Activity return will be selected to save the contents.in onActivityResult:

Bundle extras = data.getExtras();  
if(extras != null ) {  
    Bitmap photo = extras.getParcelable("data");  
    ByteArrayOutputStream stream = new ByteArrayOutputStream();  
    photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);  
        / / The stream to write to a file or directly using the
}

和看<一href="http://stackoverflow.com/questions/1973359/android-crop-an-image-after-taking-it-with-camera-with-a-fixed-aspect-ratio">this帖子这也是帮助您进行裁剪图像中的Andr​​oid

and see this post which is also help you for cropping image in android

这篇关于从图库中选择机器人当裁剪图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆