Android crop image like camscanner

前端 未结 2 1453
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-25 08:46

I am developing a project which requires the image crop feature like camscanner android application,when a picture is taken and when user clicks the crop button, a rectangle

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-25 09:25

    thanks @jhansi for this amazing library but the problem of this library(Android Scanner Library) is the image orientation is always 90 degree rotated, we can solve it like this.

    Solution in Kotlin

    In OnActivityResult it gives you bitmap and this bitmap you can pass to "Bitmap.roate" method.

    Use it like this: val rotatedBitmap=bitmap.rotate(90f) imageView.setImageBitmap(rotatedBitmap)

    Paste this method in your activity: fun Bitmap.rotate(degrees: Float): Bitmap { val matrix = Matrix().apply { postRotate(degrees) } return Bitmap.createBitmap(this, 0, 0, width, height, matrix, true) }

提交回复
热议问题