Implement a Take Picture + Crop or use premade Intents?

断了今生、忘了曾经 提交于 2019-12-04 20:16:44

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);
}

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

Just a note on open source / 3rd party crop libraries - you should look over the source and make sure they are not using a crop intent (e.g., com.android.camera.action.CROP) as CommonsWare points out here and in his helpful blog post: http://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html

I have been evaluating different crop libraries/open source on github and some of them are using a crop intent.

This, of course, assumes you care that cropping should work on all Android devices :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!