安卓:裁剪图像,以特定的大小 [英] Android: Cropping an image to specific size

查看:238
本文介绍了安卓:裁剪图像,以特定的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目的是让用户从库中选择一个图像,然后有一个种植活动上来。但是,我需要定义裁剪掩模被锁定到一定尺寸,然后,用户只需重新定位它,以显示图像的一部分的矩形。

这是如何做到这一点做任何想法?

感谢

-T

解决方案

 意向意图=新的意图(Intent.ACTION_GET_CONTENT,空)
            .setType(图像/ *)
            .putExtra(裁剪,真)
            .putExtra(aspectX宽)
            .putExtra(aspectY,高度)
            .putExtra(outputX宽)
            .putExtra(outputY,高度)
            .putExtra(规模化,真)
            .putExtra(scaleUpIfNeeded,真)
            .putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(F))
            .putExtra(OUTPUTFORMAT,Bitmap.Com pressFormat.JPEG.toString());
 

My intention is to have the user pick an image from the gallery, then have a cropping activity come up. However, I need the rectangle that defines the cropping mask to be locked to a certain dimension and then the user simply repositions it to display a portion of an image.

Any ideas on how this would be done?

Thanks

-T

解决方案

Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null)
            .setType("image/*")
            .putExtra("crop", "true")
            .putExtra("aspectX", width)
            .putExtra("aspectY", height)
            .putExtra("outputX", width)
            .putExtra("outputY", height)
            .putExtra("scale", true)
            .putExtra("scaleUpIfNeeded", true)
            .putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f))
            .putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());

这篇关于安卓:裁剪图像,以特定的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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