作物Android的一个固定大小的图片作物、大小、图片、Android

由网友(丶晴天娃娃 也有悲哀ゝ)分享简介:我想裁剪图像,但我希望能够将裁剪区域设置为完全640px x 640px。我想prevent从裁剪到一个非常小的区域中的用户。所以基本上我会preFER有对种植面积固定的高度和宽度。我已经看过成几个第三方库,但没有看到解决这个问题。我怎样才能做到这一点? I am trying to crop an image bu...

我想裁剪图像,但我希望能够将裁剪区域设置为完全640px x 640px。我想prevent从裁剪到一个非常小的区域中的用户。所以基本上我会preFER有对种植面积固定的高度和宽度。我已经看过成几个第三方库,但没有看到解决这个问题。我怎样才能做到这一点?

I am trying to crop an image but I want to be able to set the cropped area to exactly 640px x 640px. I want to prevent a user from cropping down to a really small area. So basically I would prefer to have a fixed height and width for the cropping area. I have looked into several third party libraries but don't see solving this problem. How can I do this?

推荐答案

我会使用这些解决方案之一:

I'd use one of these solutions:

https://github.com/jdamcd/android-crop https://github.com/edmodo/cropper https://github.com/jdamcd/android-crop https://github.com/edmodo/cropper

这两个似乎是适当的为您解决问题和确保覆盖更多优势的情况下,设备和其他Android的东西只是为了更加稳定可靠。

Both seems to be appropriate to solve your problem and for sure cover more edge cases, devices and other Android stuff just to be more stable and reliable.

编辑: 我已经介绍了一些更改,以 Android的作物,现在你可以使用 withFixedSize(INT宽度,诠释高)来以像素为单位设置固定种植面积。 看起来是这样的:

I have introduced a few changes to android-crop and now you can use withFixedSize(int width, int height) to set fixed cropping area in pixels. Looks like this:

 private void beginCrop(Uri source) {
        Uri outputUri = Uri.fromFile(new File(getCacheDir(), "cropped"));
        new Crop(source).output(outputUri).withFixedSize(640, 640).start(this);
    }

检查整个code在我github上https://github.com/mklimek/android-crop/tree/newfeature_fied_size_crop.您可以克隆构建和运行示例工程。 希望这将帮助你:)

Check full code at my github https://github.com/mklimek/android-crop/tree/newfeature_fied_size_crop. You can clone build and run example that works. Hope this will help you :)

阅读全文

相关推荐

最新文章