实现一个拍照+裁剪或使用premade意图? [英] Implement a Take Picture + Crop or use premade Intents?

查看:149
本文介绍了实现一个拍照+裁剪或使用premade意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是在一个Android应用程序,它拍照,农作物,并做一些额外的东西中间。我希望做的我自己的熟制,但是当我测试在不同的地方的问题就来了。图片显示旋转在某些情况下,而在其他不正确裁剪(如他们有一个额外的余量各地(看原始照片的额外空间),左右)。

I'm in the middle of an Android app which takes a picture, crops it and does some extra stuff. I was hoping to do my own cropping system, but the problem comes when I test in different places. Pictures appear rotated in some cases, and not correctly cropped in others (like they had an extra margin around (seeing extra space of the original picture), or so).

更多关于的是,我使用意图考虑。这将释放我从拍照疯狂,裁剪,并会添加一个有趣的获得库选项,我还没有实现。 作物意图可能并非在每个机器人(因为它带有香草摄像头应用程序,某些设备根本没有的话),因此外部库应该是对我的路了。

More on that, I've considered using Intents. This would release me from the picture taking madness, the cropping, and would add an interesting "get from gallery" option, which I haven't implemented yet. Crop intent may not be in every Android (as it comes with the vanilla Camera app, and some devices just don't have it), so external libraries should be on my way, too.

不过,我使用的作物和拍照是自动,这意味着一个按钮了一个正方形图片(从相机中取出一个正方形视图)的方式,被裁掉在同一时间(和一些后期处理太),而不会发出用户,和我见过的作物库不工作的方式(他们打开一个新的活动)。

However, the way I was using crop and picture taking was "automatic", meaning a single button took a square picture (out of a square view of the camera), being cropped at the same time (and with some post processing too), without issuing the user, and the crop libraries I've seen don't work that way (they open a new Activity).

现在问题来了:它会更好离开工作意图(和/或外部库),并重新考虑应用程序的逻辑,还是坚持目前的code和做边沿作出修改的,因为它们出现(旋转,一些设备,而不是在其他作物不同,等等)?

PD:我知道这个问题可能不会像开发,紧他人(有些人会说:没有台词的code>无左右),但它确实是一件关系到编码为好,所以我觉得没有更好的地方来问吧。

推荐答案

Facebook和Instagram的已成功地用自己的库或第三方code做到了。在已经开始在自己的种植图书馆工作,我建议你把它所有的方式,边缘的情况下,优化技术和解决方案将在那里,但毫无疑问,你会在控制。 例如,你谈到的定位问题可以这样处理:

Facebook and Instagram have succesfully done it with their own libraries or third party code. Having already started work on your own cropping library i suggest you take it all the way, borderline cases, optimisations and workarounds will be there, no doubt but you will be in control. for example, The orientation problem that you talked about can be handled like this :

orientationColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.ORIENTATION);     

cursor.getInt(orientationColumnIndex)
if(orient == 90 || orient == 180 || orient == 270 ){
  Matrix matrix = new Matrix();
  matrix.postRotate(orient);
  result = Bitmap.createBitmap(result, 0, 0, 4*screenWidth/15, 4*screenWidth/15, matrix, true);
}

使用默认的Andr​​oid意图进行裁剪,如你所说,心不是很可靠的广泛的潜在用户群做一个应用程序。

Using the default android intent for cropping, as you suggested, isnt very reliable for an app made for wide potential user base.

这篇关于实现一个拍照+裁剪或使用premade意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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